-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration
It's time to work with our Application. According to our Getting started and Setup, we now have:
composer.json
composer.lock
vendor
public
config
app
in our working directory. Let's assume that we have a domain call www.example.com for live and we will be coding/deploying in localhost. It's also the time to decide what's the namespace we would like to use in our project, but for this configuration we will use app for our namespace.
- Create a new PHP file
config\routeController.phpand add the following code.
<?php
namespace app;
class routeController extends \letId\request\http
{
/*
$host: Application (folder) => hostname (regex without slashs)
*/
protected $application = array(
'example'=>array(
'example.com','.example.com','.example.', 'localhost'
)
);
protected $directory = array(
'template'=>'template',
'language'=>'language'
);
protected $configuration = array(
'language_default'=>'en'
/*
ANS: the Application's Namespace!
*/
'ANS'=> __NAMESPACE__
);
/*
ADR: the Application's Directory!
*/
const ADR = __DIR__;
}- Create a new PHP file
public\index.phpand add the following code.
<?php
/**
* Initiate autoload
*/
require_once '..'.$_SERVER['PHP_SELF'];
/**
* Initiate HTTP_HOST, REQUEST_URI according to the Application's Routine!
*/
$application->request();
/**
* Initiate: configurate, Configuration
*/
$application->initiate();
/**
* Response: Html, termination execute
*/
$application->response();- Create a new PHP file
index.phpin root directory and add the following code.
<?php
/*
letId PHP Framework
*/
define('app_initiated', microtime(true));
require_once 'vendor/autoload.php';
$application = new app\routeController();
if (__FILE__ == $_SERVER['SCRIPT_FILENAME']) {
$application->requestBefore();
require_once 'public/index.php';
}📌 Most apache/nginx or other server that served PHP will use index.php for default document by default. If the server you are working with has different configuration, you have to follow it.
Now, we need to tell Composer to autoload our configuration directory config by adding the following lines to composer.json
...
"autoload": {
"psr-0": {
"app": "config/"
}
}
...
That's it for the basic and primary configuration. We now have to give a command in terminal/command prompt to generate our configuration
php composer dump-autoload -o
Finally browse your application http://localhost/, if you see an error page that saying Invalid configuration you are on the right path of creating your application with letid. Invalid configuration dedicate that there is no application exists in app directory!
📌 We assume that you have installed Composer and the server pointed to public directory that we've just created.
emoji icon indicate
- Date/Time 📅
- Callable child Method 〰️
- Core 💫
- Todo 💥
- Need to be improved/fixed 🔨
- Stop 💤
- New 💡
- Note 📌
- Updated/Improved/Fixed 🌱
- Version/Target 🚩
- Changed/Modified: 🔪