Closed theanujrajput closed 6 years ago
What exactly would you like to change? Pretty much everything can already be modified.
@anuj331991 the proposal of a modular structure in Laravel could be interpreted in different ways; what would be useful is describing your interpretation, and what you think should change to support this.
Furthermore, if you really want to win people over and have this implemented, presenting examples and use-cases would be a welcomed bonus. It would offer an idea of when one would use it and why it would be advantageous.
Even I was thinking the same. But I think what if we extend symfony bundle system and initiate a package which will handle bundling stuff...
This is kind of advanced feature which not all project will be required by default... But it will help in building the large application.
I have dropped a message in larachat #package channal to know if anyone did it already or not.
Also, I was thinking that if we run a command
php artisan make:controller ControllerName --module=name
then that file should be created in registered module directory...
I think this package is sufficient to solve our module problem... https://github.com/caffeinated/modules
Sounds a lot like you just want a package. IMO it is best to leave this "module" engine out of Laravel's core since packages do just fine. If you want a module engine for your project, nothing is stopping you from including it.
I just read through Symfony's documentation on The Bundle System, and I don't see a significant difference between that and Laravel's own Packages; which already allow you to encapsulate functionality.
If you want to develop first-party packages (modules/bundles), you have, as far as I know, at least a couple options.
Add a new directory to the root of your project (src
, or bundles
would suffice), and store all internal packages in there.
The structure of each package isn't significant because your Service Provider will tell Laravel exactly how to locate all of the resources like views, JS, CSS, etc. Nevertheless, I'm using the following structure to demonstrate similarities between Laravel's Packages and Symfony's Bundles.
- bundles
- Acme
- Providers
- AcmeServiceProvider.php
- resources
- views
- acme-view.blade.php
Then add bundles
to the PSR-4 namespaces list in composer.json
.
{
...
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/",
"Bundles\\": "bundles/"
}
},
...
}
Finally, add Bundles\Acme\Providers\AcmeProvider::class
to your providers list in config/app.php
.
Follow these instructions for registering a private repository in your composer.json
file. Then, like the previous example, use a Service Provider to register your package within your application.
You don't need to register a private repository in composer.json
, just append it to either require
or require-dev
, then and add the Service Provider to config/app.php
.
I thought it was possible to provide a directory when using the Artisan make
command, but I appear to be mistaken. Being able to specify a destination would be useful, not just for people who want to build modular applications. This change would make a good PR, and combined with the above recommendation, would make building modular applications much easier.
With all that said, this is my interpretation of a modular application. Forgive me if I am wrong, and please correct me if I am so. I am merely trying to understand the requirements and see how to accommodate them with the least amount of changes to the framework.
Hi, please add modular structure in laravel( like zend) that would be great while developing big appications having many modules..