Skip to content

Comment on The Micro PHP Manifesto's Missing Tenet

Comments

"Allow functions to be imported like classes"

I'm a micro-php sympathizer, but I'm wondering if the pendulum isn't swinging a little too far in the other direction here. Import libraries function by function? Are there really no libraries that are small and address your needs with a minimum of cruft? If we don't want to import a simple router class, maybe the solution is to trim down the class, not break it up into discrete functions to be imported one by one. What would a more-than-small application look like like this? I fear it'd look crazy; but I'm just speculating.

Anyway, if you really want to import functions it's not like it's impossible.

    echo "<?php function myFunk(){ echo 'hi'; }" > lib/myFunk.php
Then `require 'lib/myFunk.php';` I'm sure there are more graceful ways in other languages but this works. (EDIT: Namespaces notwithstanding ;)
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.