Logic

Controllers

App controllers extend the Core\Controller class included in Exception.
Each controller load Exception native Controller components that will be used in every method of your application so you have access to:

  • $this->http()
  • $this->date()
  • $this->mail()
  • $this->text()
  • $this->image()
  • $this->form()
  • $this->tool()
  • $this->file()
You can create a new empty controller using this command in your terminal:

php ef ctr-new CONTROLLER-NAME APP-FOLDER

Remember that CONTROLLER-NAME is the desidered controller name and APP-FOLDER is the application folder to use.

You can recall a controller into a route with this function:

getcontroller(CONTROLLER-NAME, CONTROLLER-FUNCTION, VARIABLES)

Rememeber that CONTROLLER-NAME is the controller class name (without "Controller"... example... to obtain AppController... set "App" and system creates a file named "AppController.php" into app controllers directory), CONTROLLER-FUNCTION is optional (if not declared, "index" function is default) and VARS are optional.

Models

App models extend the Core\Model class included in Exception.
Each model load Exception database ORM that will be used in every method of your model so you have access to:

  • $this->data()
You can create a new empty model using this command in your terminal:

php ef mdl-new MODEL-NAME APP-FOLDER

Remember that MODEL-NAME is the desidered model name and APP-FOLDER is the application folder to use.

You can recall a model into a controller or directly in a route with this function:

getmodel(MODEL-NAME, MODEL-FUNCTION, VARIABLES)

Rememeber that MODEL-NAME is the model class name (without "Model"... example... to obtain UsersModel... set "Users" and system creates a file named "UsersModel.php" into app models directory), MODEL-FUNCTION is optional (if not declared, "index" function is default) and VARS are optional.

Views

App views are based on Twig template engine.
By default every view is cached into apps/APP-NAME/cache folder, you can change cache configuration into app env file.

You can recall a model into a controller or directly in a route with this function:

getview(HTML-PATH, VARIABLES)

Rememeber that HTML-PATH is the path of twig html template into apps/APP-NAME/views without ".html" or ".twig" extention and VARS are optional.


You can exlude Twig engine and use PHP file as view (in some case can be useful). You have to recall a PHP view with

getview(PHP-PATH, VARIABLES, 0)

Rememeber that PHP-PATH is the path of php template into apps/APP-NAME/views without ".php" extention and VARS are optional.

Snippets

A PHP code snippets is a code business logic useful to re-use in your controllers, routes or view.
By default $app object is included in every snippet.

You can create a new empty snippet using this command in your terminal:

php ef snp-new SNIPPET-NAME APP-FOLDER

Remember that SNIPPET-NAME is the desidered snippet name and APP-FOLDER is the application folder to use.

You can recall a snippet into a controller, view or directly in a route with this function:

getsnippet(SNIP-PATH, VARIABLES)

Rememeber that SNIP-PATH is the path of php snippet into apps/APP-NAME/snippets without ".php" and VARS are optional.

APP constant

Exception provides a global constant called APP with current environment and application variables.
This is the list of available variables:

  • name
  • version
  • domain
  • ssl
  • url
  • uri
  • permalink
  • path
  • app
  • assetsurl
  • assetsdir
  • storageurl
  • storagedir
  • ftpurl
  • ftpdir
  • timezone

$app singleton

Exception provides an optional $app singleton pattern that you can use into every part of the framework using "global $app;" and $app->method().

Custom classes

You can create your own custom classes putting your code into apps/APP-NAME/libraries folder and using them into your controllers. To do it all you have to do is:

  • create a file PHP into libraries/NameSpaceFolder/ClassName.php
  • create NameSpace and Class into ClassName.php file
  • include it into a controller or into your codebase within Use NameSpace\Classname;
  • initialize your custom class into Controller Costructor within $this->customvar = New NameSpace\Classname;
An autoload engine provides to include all in your code-base.

Third parts vendors

You can install every third parts vendor you desire into your application compiling the apps/APP-NAME/composer.json file and running "composer update" command line in your terminal.

Applications configuration

You can set apps configuration as constants variables compiling apps/global.php file for "all apps" configuration or compiling apps/APP-NAME/config.php file for any specific app.

Exception CLI

Exception provides a native CLI suite (php ef) useful to develop quickly any project.
You can find a terminal commands list using "php ef help".

Tasks and crons

Exception provides a CLI that lets you to exec a curl to an URL so you can run schelude crons to your pages.
If you need you can protect them with a secret key.

To set cron in your server:

crontab -e

And edit it with (for example):

* * * * * /usr/bin/php path/to/framework/ef TASK-URL

Backups and dumps

Exception provides a CLI that lets you to exec backups and dumps in easer way.
The options are:

  • Application folder backup
  • Storage folder backup
  • Assets folder backup
  • DB dump (schema and data)
  • DB schema (only schema)
For more information digit CLI:

php ef help

Test and debug

Within composer package dev dependencies you have installed Kint debugger and PHP Unit Test.
To use them, you have to activate debug in env configuration file.
To debug you have to compile into your business logic:

d(VAR-NAME);

If you disable debug mode in env file, all debugger snippets are not visualizable into frontend so you can keep them into production code-base if you prefer.

Do you need help?

Write me an e-mail: [email protected]