Support the ongoing development of Laravel.io →
Installation IOC Packages

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

Last updated 3 years ago.
0

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 :(

0

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');

0

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 ...

0

Sign in to participate in this thread!

Eventy

Your banner here too?

jorenvh jorenvh Joined 13 Dec 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.