Package Data | |
---|---|
Maintainer Username: | mrsimonbennett |
Maintainer Contact: | simon@bennett.im (Simon Bennett) |
Package Create Date: | 2014-05-25 |
Package Last Update: | 2014-08-07 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-19 03:22:15 |
Package Statistics | |
---|---|
Total Downloads: | 88 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 1 |
Dependency Injection for Methods in Laravel Controllers
Enabling you to use the IOC to inject into controllers methods. Why? Well somethings you have a instance of something you only want for one of a controllers methods so does not make sense to inject via the constructor.
Quick Example
public function index( \ACME\Validation\Company $companyValidation)
{ }
#Requirments
#Installing
Add To composer.json
{
"require": {
"mrsimonbennett/dipr": "dev-master"
}
}
I recommend you use a BaseController of some sort, if not your controller need to extend Mrsimonbennett\Dipr\Controller
<?php
use Mrsimonbennett\Dipr\Controller;
class BaseController extends Controller {
}
#Usage Example (needs more work)
/**
* Class ProcessController
* @package Amce\Controllers
*/
class ProcessController extends \BaseController
{
/**
* @param Request $request
*/
public function getRequest(Request $request)
{
return $request->All();
}
/**
* @param Request $request
* @param string $slugFromRouteConfig
*/
public function getRequestWithURLSlug(Request $request, $slugFromRouteConfig)
{
}
/**
* @param User $userFromRouteConfig
* @param Request $request
* @param string $randomSlugStringFromRouteConfig
*/
public function getRequestWithModelFromRouter(User $userFromRouteConfig,Request $request, $randomSlugStringFromRouteConfig)
{
}
}
As you can see objects are always first before strings/ints loaded using the router.php
#How It works
If you get stuck you can always use var_dump the func_get_args() and see whats going on