Service providers are the central place of all Skytells application bootstrapping. Your own application, as well as all of Skytells's core services are bootstrapped via service providers.
But, what do we mean by "bootstrapped"? In general, we mean registering things, including registering service container bindings, event listeners, middleware, and even routes. Service providers are the central place to configure your application.
If you open the
Application/Misc/Settings.php file included with Skytells, you will see a providers array.
These are all of the service provider classes that will be loaded for your application.
Of course, many of these are "deferred" providers, meaning they will not be loaded on every request, but only when the services they provide are actually needed.
In this overview you will learn how to write your own service providers and register them with your Skytells application.
Service Providers Are Optional¶
Unlike other frameworks like Laravel which requires Service Providers to run the Containers,
In Skytells Framework Service Providers Are Optional
Service Providers vs Libraries & Handlers¶
Skytells's Service Providers feature provides a means to tap into and modify the inner workings of the framework without hacking the core files. When Skytells runs it follows a specific execution process, diagramed in the Application Flow page. There may be instances, however, where you'd like to cause some action to take place at a particular stage in the execution process. For example, you might want to run a script right before your controllers get loaded, or right after, or you might want to trigger one of your own scripts in some other location.
Runtime Flow Chart¶
Service Providers Architecture¶
In order for you to understand the Service Providers Architecture Please read this section carefully.
According to the Framework's Main Architecture
Application/Misc folder contains several other folders, which are explained below :
1 2 3 4 5 6 7 8 9 10 11 12 13 14
[-] Application [-] Misc [+] Config [+] Helpers [+] Handlers [+] Hooks [+] Libraries [+] Packages [+] Providers [+] Phrases - Settings.php [+] Public [+] Resources [+] Storage
Now lets open up the
Providers folder from the following path :
At the moment you'll see
two sub directories and
one ServiceProvider file.
1 2 3 4 5 6 7 8 9 10 11 12
[-] Application [-] Misc [+] Config [+] Helpers [+] Handlers [+] Hooks [+] Libraries [+] Packages [-] Providers [+] Contracts [+] Services * AppServiceProvider.php
Lets Explain step by step whats inside
|Contracts||DIR||This directory contains all Contracts which used for service providers implementation, All Interfaces or contracts associated for a ServiceProvider must be stored here.|
|Service||DIR||This directory contains all Services which used to perform the service provider's functionality, All Services controlled by ServiceProvider File must be stored here.|
|AppServiceProvider.php||FILE||This is a dummy ServiceProvider php file to show you how Service Providers works, All Service Providers must be stored in Providers dir.|
What is Contracts ?¶
Skytells's Contracts are a set of interfaces that define the core services provided by the framework. All of the Skytells contracts live in their own GitHub repository. This provides a quick reference point for all available contracts, as well as a single, decoupled package that may be utilized by package developers.
What is Services ?¶
Services are the heart of the ServiceProvider, which contains the whole functionality for your Service Provider php file.