Laravel - One CMS / multiple sites

霸气de小男生 提交于 2021-02-10 15:53:40

问题


Laravel Folder Structure

I developed a CMS with laravel which I want to use for multiple websites. My goal is to have a single place to develop my CMS further and don't have old "CMS code" in older websites.

The problem is that I dont know how to structure my laravel folder structure. This is what I have in mind:

  • --cms
    • --website-1
    • --website-2
    • --website-3

each website must have it's own - public folder - .env file (or config for database and other website specific settings) - routes - resources(views, assets) - controller('s) - lang files - etc.

Development Environment

In development I want to use the website's domain(website-1.test) as indicator what website folder should be used.

Production Environment & Git

I use forge to deploy my websites. My idea is to have a git repository for the CMS and a git repository for each of the websites. In the websites repositories I only push the website folder. In the CMS repository the whole project is saved but all the website folders are .gitignored.

So for the production server i had this folder structure in mind:

  • CMS (git repo)
    • website (git repo)

When updating the front of a website I push the website repo, if I want to update the CMS I push the CMS repo.

Conclusion

Bare in mind that these are my first thoughts and I am aware that my ideas might not be possible at all. I'm looking for advice and suggestions for my situation. If it can be achieved in another way or a better way I'd be glad to receive advice on that.

Thanks in advance!


回答1:


Ok . It is not posible in same project. But you can make subdirectories for you domain name. It will become website-one.yoursitename.com. And this each subdirectory will have its own files. Thats all you need to accomplish what you want. Regards.




回答2:


I have two initial ideas of how what you are asking for potentially could be achieved:

  • API

    Make one repo for backend creation through CMS in witch you can create multiple APIs for various sites. Then make a front-end repo for each site that calls the corresponding API.

    https://laravel.com/docs/5.8/eloquent-resources

  • Package

    You could make a composer package for your cms code and then pull that package in to each of your website project

    https://blog.jgrossi.com/2013/creating-your-first-composer-packagist-package/



来源:https://stackoverflow.com/questions/57195573/laravel-one-cms-multiple-sites

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!