Jump to content

Using .htaccess for auto_including files in framework


Go to solution Solved by mac_gyver,

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?

  • Solution

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.