S
S
Serverprom2018-01-31 21:14:48
PHP
Serverprom, 2018-01-31 21:14:48

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_modulesare vendoradded to .gitignore, so they are not in the screenshot):
5a7206e4392be881951760.png
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

2 answer(s)
S
Serverprom, 2018-02-01
@Serverprom

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.

@
@smple, 2018-02-01
_

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

deployment is slightly different but also quite simple

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question