Laravel - One CMS / multiple sites - php

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!

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.

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/

Related

Deploying a PHP CMS with Capistrano

I have recently started playing around with Capistrano for my PHP projects, I have it working great on a static site, however the majority of my projects are built on a CMS, the most common one is Concrete5.
The problem I am having when it comes to a CMS driven sites is that a bunch of the content of the site is uploaded files which I do not want in my git repository but they need to exist within a folder that is in my repository. As an example, all of my code within a concrete5 site lives inside /application, but the user uploaded files live in /application/files. How can I preserve this folder between versions?
I have done a ton of googling on this and haven't been able to find a decent answer, I'm not sure if I am searching for the correct term though.
Many thanks in advance.

Laravel 5.2 - How do I release my Web App to GitHub?

So I’ve just finished developing my Laravel 5.2 web application that uses AdminLTE. It is an Asset Management System with some budget and invoice functionality, which will assist me in making my full-time job as a Systems Manager easier.
It’s not the most complicated app, but I’m proud of it, so I want to share it on GitHub, so others might be able to make use of it, as well as having my code available for future when I start applying for development jobs.
Now I’ve tried my best Google skills, but I just cannot figure out how to go about sharing my code on GitHub. I've used Bitbucket during my development phases, as I wanted to keep it private.
If anyone can please direct in the right direction about what steps I should be taking now to actually share my app out there. Should I be looking at something like Packagist instead, as I’m sure I’m not supposed share Laravel along with my web app. Any help will be greatly appreciated.
This question is not about how to upload my project to GitHub, but specifically about what the correct procedure is for Laravel projects and how to share them for others to easily use.
You just need to create a project repo and upload all your project code there.
If you didn't modify any core file in vendor directory, then upload the all code except vendor directory.
once uploaded, add up some readme.md file to tell some guideline/instruction for installation the project.
make your repo public so other can access it

Can a CMS be powered by a Git repository?

I made a one-off CMS for a client of mine a while ago, however it was powerful enough that I used it again on a number other projects. Now that I need to manage it, I want to be able to update all of the deployments via a single update.
I'm wondering if I might be able to have the CMS simply include files from a GitHub repository. Is there a way to do this? Something like:
<?php
require('URL TO MEDIA UPLOAD MODULE AT GITHUB');
require('URL TO PAGE MANAGEMENT MODULE AT GITHUB');
//etc...
?>
Eventually the CMS will have a number of different modules for a number of different business types (real estate, retail products & services, etc) that will be included based on the modules listed for the specific deployments needs.
I just want to store everything in one place and have each deployment updated when I commit a change to the repo.
Is this possible? If not, any suggestions?
I have no idea about storing files on Github.
However, I do have another suggestion to get to your goal:
If your projects reside on the same server and you have root access to the server, you could have the core files in 1 location. With symlinks you can have the projects make use of that same directory. You will never have to deploy again since you only have to update 1 set of files.
Just make sure that theres a way to store/load the templates and individual user settings apart from the core files.

Using GitHub for an existing website to track my own and vendor code changes

I'm going to implement version control for a project via GitHub. It's a website using mostly PHP and JavaScript. And we're switching from one script to another. I'm using cPanel / ftp to access the files. I would prefer not to mess around with apache config files.
/home/website/ - home directory
/home/website/public_html/ - document root for website.com - has existing php script files which will be overwritten once the beta site is tested to be working properly
/home/website/public_html/beta.website.com/ - document root for beta.website.com - has existing php script files which have been minimally modified from the original vendor source. ie header / footer / config files.
/home/website/public_html/orig.website.com/ - a possible directory where I could update the original vendor files?
/home/website/public_html/addon-website.com/ - document root for another addon domain - completely separate website has nothing to do with the project
This script is to be used on many different websites. The difference would be in:
config files
template files
website specific changes
I have the original vendor source files on my local computer but no local web server. I need help in initial setup. How should I set things up so I can track all of the following:
track changes to the original vendor files done via patches and updates
track changes to 1 or many versions of the original script installed on different websites
track changes to a beta which has my own modifications to the vendor files
track website specific changes
push changes from vendor files to where I do my own modifications
push changes from my modifications to all different websites / website specific
I had a look at how do I maintain divergent code on github but I need more specific instructions than what is provided there. Should I even be trying to do this all in one repo with many branches / forks / whatever?
It would be beneficial to have an integration branch and each party to work on features that are merged there. This is the workflow that I developed with my colleagues and has worked out very well:
http://dymitruk.com/blog/2012/02/05/branch-per-feature/
For an introduction of Git itself, this is a very good resource:
http://git-scm.com/docs

Eclipse: Share a large framework with multiple projects?

We develop in PHP and HTML/Javascript.
Over time we developed a very big source code library, that contains a couple of hundred PHP and Javascript libraries, that we use for every project. The framework resides its own svn-repository, that we include with an external svn link in each project.
The problem is, that the entire framework itself is about 800MB now.
With only a few projects that we worked on, this wasn't really a problem, but now we have about 30 projects, that all contain a FULL copy of the framework, which takes up a lot of space, and requires constant updating of each copy.
Somehow I would like to have the framework outside the project folders. I've read about referencing other projects in Eclipse, but couldn't really get it to work.
How do you setup the include paths so that each projet 'thinks' that the framework is normally inside the project folder? And can you make a virtual link in an Eclipse project to edit files in the framework just as you would normally do, and get code assist for the libraries too?
One of the main problems is that all our code (and some libraries in the framework itself too) relies on the fact that the framework is in a folder 'framework' inside each project. I'd rather not change all those references to a different path, so maybe I need some .htaccess trick to make this work...
Does anybody else follow the same procedure?
Any advice ?
can you use the "big" project as target platform?
why-create-a-custom-target-platform
If you define it as target platform, the sources are available in your workspace, but they are placed in 1 folder for multiple workspaces. the workspaces will link to the platform, but will not check them out.

Categories