Answer the question
In order to leave comments, you need to log in
How to properly organize the site structure in PHP?
Hello!
I am writing a site in PHP, using Composer, NPM (with modules like Moment.js, etc.) and Webpack, I also plan to write unit tests for PHP code, I also plan to add part of the frontend to Vue.js.
In the bowels of the back-end, a template engine plows, which is fed with templates from a separate folder.
The sources are uploaded to Bitbucket, I upload all changes to the site manually from the computer.
The site is not a SPA, almost without an API.
Now the site looks something like this (the and folders node_modules
are vendor
added to .gitignore
, so they are not in the screenshot):
All the JS code is inside the folders with templates.
I would like to somehow separate PHP and JS sources, tests, templates for the template engine, and what Webpack eventually collects and what goes to the site.
Can you please tell me how to organize the structure of the site?
Thanks in advance!
Answer the question
In order to leave comments, you need to log in
Thank you all very much for your advice! Of course, it’s impossible to do everything “according to science” completely, since the site does not have a single entry point and the front-end generates PHP, but I understood the basic ideas.
i do something like this
in the project folder i have a www or frontend folder inside it is package.json and here is the whole frontend of the site
there is also an api or backend folder inside it is composer.json and here everything related to the backend the
backend is usually placed on the api subdomain .project and the front is available in the main path
for isolating environments, I use vagrant or docker or whatever, the config is in the root of the project and there are scripts that can deploy the environment again.
launch development environment
vagrant up // или докер или любая другая виртуализация
cd frontend
npm run dev
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question