For my final project at school I'm going to build a Laravel 5 package. Now the past days I'm experimenting with package development, I have never done this before. I succeeded to work with routes, views, published javascript files etc. But the question I can't seem to solve is how to use controllers in my package?
Quote from the documentation:
Note: If your package is using controllers, you will need to make sure they are properly configured in your composer.json file's auto-load section.
But where and how do I exactly load my controllers? My package structure:
edit screenshot: screenshot can be found here
Anybody who can help me and/or give me a good example or tutorial on this one?
Thanks a lot, Joren
Good question. I'm looking for the same answer.
I found this - http://stackoverflow.com/questions/28378460/laravel-5-package-development/28383338 - but trying workbeanch version and manual - both give me an error :(
I fixt it, the solution was to autoload my controllers folder in the composer.json file of my package. After that you can access the controller in your routes.php file (in your package) in this way
Route::get('/pathtoroute', 'vendorname\Packagename\Controllers\MyController@myFunction');
In the beginning I didn't have much luck with the workbench and then publishing it from the workbench, so I just started building packages and dealing with composer updates wiping out my code. To get around that issue I just used git and made my packages git repos and then ran a few commands all over again. PITA but it works for me ...
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community