laravel_tutorial
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Laravel<br />
dd($this->myclass);<br />
}<br />
}<br />
Step 3: Visit the following URL to test the constructor injection.<br />
http://localhost:8000/myclass<br />
Step 4: The output will appear as shown in the following image.<br />
Method Injection<br />
In addition to constructor injection, you may also type — hint dependencies on your<br />
controller's action methods.<br />
Example<br />
Step 1: Add the following code to app/Http/routes.php file.<br />
app/Http/routes.php<br />
class MyClass{<br />
public $foo = 'bar';<br />
}<br />
Route::get('/myclass','ImplicitController@index');<br />
Step 2: Add the following code to app/Http/Controllers/ImplicitController.php file.<br />
app/Http/Controllers/ImplicitController.php<br />