Matt Stauffer has a new post to his site today showing you how to extend Laravel's Application class to enhance its handling with other handy features.
It's seldom that we need to extend Laravel's core, and even when we do, it's most likely we're going to extend specific components, which is detailed in the docs. However, all of these instructions presume you're using the core Laravel Application (IOC Container) to extend the other classes. What if you want to extend the Application itself?
The example he provides is from his own real-world experience, based around changes they wanted to make in the default folder paths for things like the "storage" or "public" directories. He shares the three simple steps to making this custom handling work:
- Extend the class
- Register it in your application's bootstrap
- Override/extend the current methods to add in your own functionality
In this case, changing the default paths is something that's under discussion already, but it gives a good simple example of changing that default functionality.
Link: http://mattstauffer.co/blog/extending-laravels-application
没有评论:
发表评论