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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s