M
M
maxzbs_web2020-06-01 08:47:36
Software Deployment
maxzbs_web, 2020-06-01 08:47:36

How to properly deploy a laravel project?

Good afternoon, I'm interested in the question - how to work and deploy a laravel project correctly.

For example, now I am developing completely via FTP directly updating the changes on the site. But this is not relevant if the project is visited by many people and can see an error at any time during the update.

So, I have never worked with git and other systems. As far as I understand, development can be done locally, but I don’t understand how the database will then be pulled up (separately local and separate server or shared?). Also install git (version control system). Then work locally, and when everything is already tested, upload it first to git, and then somehow get all the changes on the server.

I tried to explain the problem as much as possible, I hope I succeeded. Thanks, have a nice day!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
Northern Lights, 2020-06-01
@php666

I just don’t understand how then the bd will pull up
no way. why do you need combat data on the local area? It is enough to restore from a backup file from a combat server once a week/month. At you not so often tables change I think.
About structure of tables - there are migrations. It's written in the Laravel docs.
By guitar and composer. The simplest:
You need a local git. For windows here .
Composer (or composer.phar archive ) is needed. You
initialize the repository on github and
merge this empty repository locally to your computer by doing
cd C:/govnocode
git clone https://github.com/youprofilename/reponame.git in the gitbash utility .
you throw your code into C:/govnocode, after specifying in gitignore what should not be in the git - log files, files with user images, all sorts of garbage files like test.php, etc.
you do
git commit -a -m "govnocode"
git push origin master
your shitcode will fly into the repository - this will be the first push of the code to the repository
on the server, you make a new combat directory, you execute
git clone https://github.com/youprofilename/reponame.git .
from git all files will arrive to your host
at home edit files, do
git commit -a -m "govnocode version 2"
git pull origin master
git push origin master
the changes will go into the repo. when it is necessary to pull up on the server.
you do git pull origin master on the server
, you run the kmposer to pull dependencies, there are docks on the network, you need to run both on the local PC and on the server

C
Cyril, 2020-06-01
@SH8DER

I am not professionally engaged in development, and even more so I am not familiar with Laravel. BUT
You develop locally, you also have a local database with fake data (Laravel has something like Facker Seeds), you change the structure through migrations. You write tests for each new feature using Composer.
You must have a repository with several branches, at least 2 - dev - master.
When you made a new feature on the local, push it to the dev branch, the changes fly away, let's say to GitLAb - the CI script is launched there, the tests are run, if everything is ok, then the branch with this feature is merged into the master, after which the hook and the production server are launched makes a Pull master, after which scripts for updating Composer dependencies, migrations, etc. are launched on the server.
Well, in general, something like this, I think the professionals will correct me, but in general, this is how development is carried out.
ps - you can also push all this into docker containers, if you wish.

Z
zorca, 2020-06-02
@zorca

Deployer will do just fine. There is a ready-made wrapper for Laravel: https://github.com/lorisleiva/laravel-deployer
The next step is to deploy on Github Actions to the stage branch, let's say, and enjoy automatically sending changes when pushing to this branch.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question