Download the PHP package ibnusyuhada/slim-tegar without Composer
On this page you can find all versions of the php package ibnusyuhada/slim-tegar. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ibnusyuhada/slim-tegar
More information about ibnusyuhada/slim-tegar
Files in ibnusyuhada/slim-tegar
Package slim-tegar
Short Description Slim Tegar is a package that designed for integrating PHP-DI and Slim Framework version 3.x.x. This package is an Slim Bridge advanced of http://php-di.org/doc/frameworks/slim.html. You don't need to extends any class of PHP-DI or Slim just to make container configuration. Slim Tegar also providing the easy way to implement Closure and MVC routes.
License MIT
Informations about the package slim-tegar
Slim Tegar
Slim Tegar is a package that designed for integrating PHP-DI and Slim Framework version 3.x.x. This package is an Slim Bridge advanced. You don't need to exteds just to make container configuration. Slim Tegar also providing the easy way to implement Closure and MVC routes.
Requirement
Slim Tegar requires PHP-DI and SlimFramework version 3.x.x.
Installation
Install Slim Tegar can do via Composer:
Usage
Basically, Slim Tegar is replacing original container of Slim (Pimple) with PHP-DI. You don't need to extend any class just for configuration dependencies. Some advance usage has been added to polish up original integration in http://php-di.org/doc/frameworks/slim.html.
Basic Usage
Slim Tegar usage is simple and easy. Initially, create an example project, let say slimtegar. Then install Slim Tegar inside that. After that, create index.php with the following simple code:
Basic Usage Controller
When you want to implement MVC pattern, Slim Tegar providing the simple way to register all controllers. First, add the following code before $app->run()
method:
second, open composer.json then put the code below:
don't forget to dumpautoload for register this namespace in composer. Third, create a directory inside slimtegar project with controllers as the name. Then create ExampleController.php file inside controllers directory with the following code:
fourth, open your lovely browser, and access URI example.
Configurations
In Slim Tegar, configuration was made easy. You don't need to extends any class of Slim or PHP-DI. What you need just create a directory, then put all your configuration files inside it. Basically, Slim Tegar has mandatory configuration directory. The name of the directory is defaultConfiguration. Inside there, you will see two files: defaultConfiguration.php and settings.php. The meaning of settings.php is same definition like in Slim (see [http://www.slimframework.com/docs/tutorial/first-app.html]) and PHP-DI (see [http://php-di.org/doc/frameworks/slim.html]). In updating settings, however, you don't need to touch these files. What you need just create another directory in your project, let say the name is config, then create a php file inside there. Let we give the name of that file as config.php then give the following code:
the code above will update displayErrorDetails
and add new item of settings. After that, tell Slim Tegar where the config directory is placed. Here the example code inside index.php
Add Dependencies
If you want to add another dependencies, however, just create a file returning an array (see http://php-di.org/doc/php-definitions.html), then put that file in config directory, after that Slim Tegar will register the dependencies automatically for you. As example, let say we want to use Slim-Twig. First, install Twig for Slim:
Second, create a file returning an array inside config directory. Let say the name of that file is view.php. Then give the following code in that file:
Third, inject the Twig service in controllers or closure. Below is the example:
don't forget to create home.twig file by your self.
What Next?
Everything what you need to use Slim Tegar is just follow SlimFramework Documentation. The different now is how the way you use dependency injection container. You are not using Pimple anymore, but PHP-DI. So, read more documentation about PHP-DI Documentations for advance usage. For more understanding, see the example usage inside Slim Tegar package.
Credits
License
The MIT License.
All versions of slim-tegar with dependencies
php-di/php-di Version ^5.3
php-di/invoker Version ^1.3
php Version >=5.5