Basically they are used as preconfigurations of the whole framework, with the exception of INPHINIT_START
that has another purpose (this I will cite last).
Constants for configuration
-
INPHINIT_ROOT
:
It is used to point out which directory you want to use as root for your project, usually it should be the same location as index.php
Note: In standard code I used strtr
to change \
to /
and rtrim
to remove additional bars that come to the right, there are some cases of variations of results in different versions of PHP that have probably been fixed, but sometimes a server for using an older PATCH version, for example in version 5.6.18 has been fixed, but the problem the server 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 in 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 named public
and system
outside of it, you can do so:
define('INPHINIT_PATH', INPHINIT_ROOT . '../system/');
-
INPHINIT_COMPOSER
:
Inlinit uses composer to manage the packages that you want to install additional to your project, but does not use composer-autoload , it uses the UtilsAutoload()
", in practice both are equal, however UtilsAutoload()
is a little more efficient, of course there may be something that works only specifically in composer-autoload
, so as a guarantee I left the option to be able to toggle, to use composer-autoload
is only set to true
:
define('INPHINIT_COMPOSER', true);
The constant INPHINIT_START
This constant has no purpose whatsoever for the operation of the framework (with the exception of class Inphinit\Experimental\Debug
, which is a class used for development), the only utility it is for you to be able to do "performance" tests, ie imagine what you want do something similar to Google's search engine:
Youcandosomethinglikethis:
<?phpuseInphinit\Routing\Route;Route::set('GET','/exemplo',function(){return'Olámundo!Suapáginalevou:'.round(microtime(true)-INPHINIT_START,4).'segundos';});
Anditwillresultinthis:
Ofcourseit'sjustanexampleandthefocusisnotthisspecifically.AsforusingtheInphinit\Experimental\Debug
class,it'srelativelysimple,justchangethesystem/dev.php
andaddthis(inDEBUGmode):
<?phpuseInphinit\Experimental\Debug;Debug::view('error','debug.error');//^--ação^--nomedaViewDebug::view('performance','debug.performance');//^--ação^--nomedaView
Commentsareforexeplicateonly
Allpageswilldisplaysomethinglikethisinthefooter:
IfINPHINIT_START
wasnotproperlysetyouwouldprobablygetanunexpectedvalue.
Notethat'debug.performance'
referstosystem/application/View/debug/performance.php
,whichyoucancustomize:
<divclass="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>