Jump to content
Sign in to follow this  
deathbeam

Using .htaccess for auto_including files in framework

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

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.