Multiple Projects using single laravel instance

前端 未结 2 467
被撕碎了的回忆
被撕碎了的回忆 2021-02-01 10:23

I am new to Laravel. As per my research on this framework I find it quite useful for my projects. However I am facing difficulty in customizing it to use a single instance of La

2条回答
  •  深忆病人
    2021-02-01 10:50

    There's not really a question here to be answered, but in general terms what you want to do is very feasible.

    You could create a directory under the apps folder for each project and namespace each of the classes in the structure you create below it. You'd then use PSR (ideally PSR-4) autoloading to make these classes accessible.

    You'd put the routes for each project in their own routes file and then include them through the main routes file, or you could create a service provider for each project, add it your app config file and use that to load the routes for that project.

    HOWEVER, all that said, this isn't what I would do. You haven't said why you want to structure your projects this way, so you may have a perfectly good reason, but personally I prefer to put common libraries into their own packages (helps to ensure clear boundaries and clean apis) and use Composer to pull them into each project.

提交回复
热议问题