Jump to content

Using .htaccess for auto_including files in framework


deathbeam

Recommended Posts

So I am working on my own PHP framework and I am using this:

php_value auto_prepend_file library/fw.php
php_value auto_append_file library/fw.php

To auto prepend and append file. In that file I have check if instance of core class located in fw.php is defined so it will not prepend and append duplicates. With this I reduced index.php code by these 2 lines

// This should be at beggining of index php
$fw = Base::getInstance();

// This should be at very end of index.php
$fw->run();

Is it good or bad way?

also, putting php settings into a .htaccess file only works when php is running as an apache module, which is uncommon on shared web hosting. so doing it the way you are trying would limit your framework to just apache servers and to just a fraction of those that have php running as a server module.

Most modern framework use autoloaders to including classes

 

Also see

http://php.net/manual/en/function.spl-autoload-register.php

http://www.php-fig.org/

 

I was not asking about using autoloader, that will defeat purpose of simplifying my code, why should I use autoloader when my framework is only single php file?

 

also, putting php settings into a .htaccess file only works when php is running as an apache module, which is uncommon on shared web hosting. so doing it the way you are trying would limit your framework to just apache servers and to just a fraction of those that have php running as a server module.

 

Oh, thank you very much for this info. I am focusing on ability to use my fw on shared hosting, so then I will scrap this idea.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.