Phalcon First ExampleBootstrapTo create any app in phalcon, firstly you have to create a bootstrap file. Bootstrap file acts as the entry-point and configuration of the application. This file handles 3 things:
To create this file we follow four steps:
AutoloadersIt loads the PSR-4 which consists of complaint file loader which is running through Phalcon C extension. Autoloaders add mostly Controllers and Models. We can also register directories consist of different file namespace. Public/index.php Dependency ManagementPhalcon is loosely coupled framework due to which all services are registered with dependency manager. All services are delivered automatically to components and services inside the IoC (Inversion of Control) container. All services are included in a class file DI (Dependency Injection) and IoC container consists of following concepts:
Directory: Phalcon\DI Factory DefaultFactory Default i.e. Phalcon\Di\FactoryDefault is the variant of Phalcon\Di. First we create the object for the DI which automatically registers most of the component. public\index.php Now, we register the "view" services with the directory address where to find the files. Now, we generate the base URL Application RequestApplication request implements MVC (Model View Controller) for the application. Under this we initialize 3 things:
public\index.php ExampleComplete bootstrap file: Output: Next TopicPhalcon Cache |