Download the PHP package bulton-fr/bfw-controller without Composer
On this page you can find all versions of the php package bulton-fr/bfw-controller. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bulton-fr/bfw-controller
More information about bulton-fr/bfw-controller
Files in bulton-fr/bfw-controller
Package bfw-controller
Short Description Controllers module for BFW
License LGPL-3.0
Homepage https://github.com/bulton-fr/bfw-controller
Informations about the package bfw-controller
bfw-controller
Module Controller pour BFW
Install :
You can use composer to get the module : composer require bulton-fr/bfw-controller @stable
And to install the module : ./vendor/bin/bfwInstallModules
Config :
All config file for this module will be into app/config/bfw-controller/
. There are one file to configure (manifest.json is for the module update system).
The file config.php
useClass
: Define if all controller will be classes (true
) or procedural file (false
).
Use it :
Create your controller files into the directory /src/controllers
.
For an object controller, you can extends from the class \BfwController\Controller
. This class adding properties $app
and $request
who are a direct access to the instance of the classes \BFW\Application
and \BFW\Request
. You can use the namespace \Controller
, it's added by the framework and corresponding to the directory /src/controllers
.
For a procedural controller, the file will be included into a closure who is into the method \BfwController\BfwController::runProcedural()
. So you will have a direct access to $this
of the class, and you will have variables $routerLinker
and $controllerFile
into the scope.
Example :
Extract from the BFW wiki, an exemple with an object controller.
Router module :
This module not manage the application routing. You need to add a router module too.
The route module have a config file to define each route. For each route, you should define a "target". With bfw-controller, the "target" value should have a specified format :
- For an object controller : An array, the first value should be the class name (with namespace), the second value the method name. Like a callable array.
- For a procedural controller : The filename with this extension. The path to the directory /src/controller should be omitted.