Where do I put events? or bindings?

Laravel offers tons of features but no strict conventions, this is something I like a lot but can be discouraging for beginners because they don’t really know where to put their code (besides the mvc paradigm)

Events and Binds need to be injected in Laravel request cycle before routing, a good way of structuring them is to create 2 files in app/ :  binds.php and events.php which you include in app/start/global.php, at the end of the file:

require app_path().'/binds.php';

require app_path().'/events.php';

There really isn’t the “correct way”, it depends on you needs and your style. The example above is just one way of doing it.

Advertisements