Basically they are used as pre-configurations of the whole framework, with the exception of INPHINIT_START
which has another purpose (this I will quote last).
Constants for configuration
INPHINIT_ROOT
:
It is used to point out which directory you want to root for your project, usually the same location as where the index.php
Note: in the default code I used the strtr
to trade \
for /
and the rtrim
to remove additional bars that come the most right, is that there are some cases of variations of results in different versions of PHP that have probably been fixed, but sometimes a server by using an older PATCH version, for example in version 5.6.18 has been fixed, but the server problem for some reason still uses version 5.6.17. Note that PHP is not the only interpreter of PHP scripts, there is also the HHVM that interprets, the idea is to ensure that there are no differences of results between different systems and versions
INPHINIT_PATH
:
This should point to the folder system
, If you want to customize the folder structure you can change the value of this constant, for example if you want to put index.php inside a folder called public
and the system
out of it, you can do so:
define('INPHINIT_PATH', INPHINIT_ROOT . '../system/');
INPHINIT_COMPOSER
:
inphinit uses Composer to manage packages you want to install additional to your project, but does not use by default Composer-autoload, he uses the UtilsAutoload()
, in practice both are equal, however the UtilsAutoload()
is a little more efficient, of course there may be something that works only specifically in the composer-autoload
, then as a guarantee I left the option of being able to switch, to use the composer-autoload
just define how true
:
define('INPHINIT_COMPOSER', true);
The constant INPHINIT_START
This constant has no purpose whatsoever for the operation of the framework (except for the class Inphinit\Experimental\Debug
, which is a class used for development), its only utility is for you to be able to do "performance" tests (or better time it took to run), for example imagine that you want to do something similar to Google’s search engine:
You can do something like this:
<?php
use Inphinit\Routing\Route;
Route::set('GET', '/exemplo', function () {
return 'Olá mundo! Sua página levou: ' . round(microtime(true) - INPHINIT_START, 4) . ' segundos';
});
And this will result:
Of course it is just an example and the focus is not this one specifically. How to use the class Inphinit\Experimental\Debug
, is relatively simple, just change the system/dev.php
and add this (in DEBUG mode):
<?php
use Inphinit\Experimental\Debug;
Debug::view('error', 'debug.error');
// ^-- ação ^-- nome da View
Debug::view('performance', 'debug.performance');
// ^-- ação ^-- nome da View
Comments are for execution only
All pages will display something like this in the footer:
If the INPHINIT_START
was not set properly probably would get an unexpected value.
Note that 'debug.performance'
refers to the system/application/View/debug/performance.php
, which you can customize:
<div class="box">
<h1>Perfomance</h1>
<p>Memory usage: <?php echo $usage; ?></p>
<p>Memory peak: <?php echo $peak; ?></p>
<p>Memory usage real: <?php echo $real; ?></p>
<p>Time: <?php echo $time; ?></p>
</div>