Download the PHP package headio/phalcon-bootstrap without Composer
On this page you can find all versions of the php package headio/phalcon-bootstrap. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download headio/phalcon-bootstrap
More information about headio/phalcon-bootstrap
Files in headio/phalcon-bootstrap
Package phalcon-bootstrap
Short Description A flexible application bootstrap for phalcon projects.
License MIT
Informations about the package phalcon-bootstrap
Phalcon application bootstrap
A flexible application bootstrap for Phalcon-based projects
Description
This library provides flexible application bootstrapping, encapsulating module registration (or handler registration for micro applications), event management and middleware logic assignment for mvc, micro and cli-based applications. A simple factory instantiates the dependency injection container, encapsulating the registration of service dependency definitions defined in the configuration setttings.
Dependencies
- PHP >=8.0
- Phalcon >=5.0.0
See composer.json for more details
Installation
Composer
Open a terminal window and run:
Usage
Micro applications (Api, prototype or micro service)
First create a config definition file inside your Phalcon project. This file should include the configuration settings, service & middleware definitions and a path to your handlers.
To get started, let's assume the following project structure:
and your PSR-4 autoload declaration is:
Create a config file Config.php inside the Config directory and copy-&-paste the following definition:
The handlerPath declaration must include your handlers; the best strategy is to utilize Phalcon collections. The contents of this file might look something like this:
Now, create an index file inside the public directory and copy-&-paste the following:
Finally, paste the following bootstrap code inside the Boot.php file:
Mvc applications
Create a config definition file inside your Phalcon project. This file should include your configuration settings and service & middleware definitions.
Let's assume the following mvc project structure:
and your PSR-4 autoload declaration is:
Create a config file Config.php inside the Config directory and copy-&-paste the following definition:
Now, create an index file inside the public directory and paste the following:
Finally, paste the following bootstrap code inside the Boot.php file:
Console application
Create a config definition file inside your Phalcon project. This file should include your configuration settings and service & middleware definitions.
Let's assume the following project structure:
and your PSR-4 autoload declaration is:
Create a config file Config.php inside the Config directory and copy-&-paste the following definition:
Finally, paste the following bootstrap code inside the Cli.php file:
DI container factory
From the examples above you will have noticed that we instantiated Phalcon's factory default mvc or cli container services.
Naturally, you can override the factory default services by simply defining a service definition in your config file, like so:
Then create the respective service provider and modify its behaviour:
For complete control over the registration of service dependencies, or more generally, the services available in the container, you have two options: firstly, you can use Phalcon's base DI container, which is an empty container; or you can create your own DI container by implementing Phalcon's Phalcon\Di\DiInterface. See the following for an example:
The DI factory create method expects an instance of Phalcon\Di\DiInterface.
Application factory
The bootstrap factory will automatically instantiate a Phalcon application and return the response. If you want to bootstrap the application yourself, you can use the application factory directly.
Testing
To see the tests, run:
License
Phalcon bootstrap is open-source and licensed under MIT License.
All versions of phalcon-bootstrap with dependencies
ext-mbstring Version *
ext-phalcon Version >= 5.0.0