anjanesh's avatar

Laravel and WordPress on same git on separate branches

Not sure about how to go about doing this - just checking if this is technically possible.

New project in GitHub.

main branch has an empty/hello-world index.php file.

laravel branch has an entire Laravel 12 setup

wordpress branch has an entire WordPress setup. No .env here since its all in config.php

Can I setup 2 servers (or one server and 2 apps) where WordPress is running on the wordpress branch and Laravel is running on the laravel branch.

Can there be any collision ?

0 likes
6 replies
Glukinho's avatar

Such use of Git is strange. You should have three repositories, with three projects (laravel, wordpress, hello world), branches are used for developing a single project, not a project per branch.

Tray2's avatar

I agree with @glukinho, you shouldn't mix and match your projects in different branches. Create a repository for each instead.

1 like
JussiMannisto's avatar

Git is a version control system. This isn't at all what it's meant for.

No .env here since its all in config.php

You shouldn't commit environment values to version control. In Laravel, this means excluding .env with .gitignore (done by default). In WordPress, this means excluding wp-config.php.

You should define environment variables / config in the environment where the app is deployed or developed in.

1 like
kupce's avatar

You can set up both Laravel and Wordpres on the same server using WordOps. Then set up repositories for each website. Branches unlikely.

If that interest you can go as far as setting up different php versions for each website on the same server.

Can I setup 2 servers (or one server and 2 apps) where WordPress is running on the wordpress branch and Laravel is running on the laravel branch.

Jsanwo64's avatar

Yes, it’s technically possible to run Laravel and WordPress from separate Git branches and deploy each branch to a different server or app, and there will be no runtime collisions as long as they’re deployed in isolation with separate databases. However, this is not recommended: Git branches are meant to represent versions of the same application, not entirely different applications. Using branches this way leads to operational problems with CI/CD, releases, rollbacks, and long-term maintainability, even if the code itself never conflicts. The better practice is to use separate repositories for Laravel and WordPress and deploy them independently, even if they live on the same server.

Please or to participate in this conversation.