Reference

Last updated: Jan 17, 2017

Configuring

Speedy PHP Framework comes in a ready to run format but you still might need some tweaks for application which can be done in the config file located at App/config.php.
The config file contains an array of values that can be accessed project wide using the $_ENV super global variable.
More keys can be added to the config which you wish to access site wide.
The pre-defined variables are:
'app_key' => '$omeRadomKeyofTHEapplication' -> Used to encrypt api keys and other secure resources
'debug' => true, -> Defines the debug mode of the application
'timezone' => 'Asia/Kolkata', -> Sets the default timezone of the application
'cors' => '*', -> Sets the Cross-Origin Resource Sharing (CORS) Header
'DB_TYPE' => 'mysql', -> DB Type (Fallback, Do not change).
'DB_ADO_DRIVER' => 'mysqli', -> ADOBD DAL driver
'DB_SERVER' => 'localhost', -> Database Host
'DB_PORT' => 3306, -> Database Port
'DB_USER' => 'root', -> Database username
'DB_PASSWORD' => 'password', -> Password to access the database
'DB_NAME' => 'api', -> Database name to be used.
'DB_CHARSET' => 'utf8', -> Database default character set.
'DB_FETCH_MODE' => PDO::FETCH_ASSOC, -> Database PDO Fetch Mode
'session_prefix' => 'spf_', -> Application Cookies prefix
'session_life' => 604800, -> Lifetime of application sessions
'cache_template' => true, -> Whether to allow Twig Template Caching
'error_pages' => [-> Error views to be loaded (Remember not to add the extension i.e. vu.php).
'404' => '404'
]

Using creator

To make your work more efficient Speedy provides you with a handy tools called creator which handles several common tasks for you.
creator is a php file which needs to be run from the command line using the following syntax:

php create <command> [optional:parameters] List of commands available:
  • init:app
  • create:controller
  • db:update
  • run:server
  • cache:clear

Routing

For a user to access pages of your web application you need to define routes.
Speedy provides a simple routing method of defining these routes, the routing file is App/Routes.php

To define a route you need to edit the App/Routes.php file and add the route following the syntax given below:

Route::<request method>('/path',<Controller@medthodName / Closure>); You can either define a method to be called which is contained in a controller by using the following syntax: Route::<request method>('/path',<Controller@medthodName>);
OR

You can define a closure for a particular request and path using the below syntax: Route::<request method>('/path',function(){
    echo "You are here.";
});
Allowed request methods are:
  • GET
  • POST
  • PUT
  • PATCH
  • DELETE
  • HEAD
  • OPTIONS
  • ANY -> Accepts all request methods