📜 ⬆️ ⬇️

Deploying the symfony development environment for Windows

Boilers boiled, sweat poured in streams, the team of developers tirelessly sawed projects on symfony.


Production on a remote VDS, Ubuntu 16, with all the necessary environment. The main repositories in GitLab - the free equivalent of GitHub. Each developer works remotely on projects on their local machines, working with the repository clone and checking all the improvements on the web server built into symfony.


Once a team to the front was attracted to a man who was working on windows, who had no idea about the deployment of the working environment. It was only at this moment that we realized that no one in the command on windows worked before. Only at this moment did the urgent task “With a little blood and with a minimum of knowledge, can you deploy an environment for developing symfony projects on Windows”.


It was necessary to write a short manual for developers who sit on windows. In the end, we decided that the manual should be in the form of an article on Habré.


image

Looking ahead, I will say right away that in order to find a solution, we started shooting from the bazooka at sparrows and only then, realizing what kind of monster we are calling, we began to look for something simpler.


What are the requirements for the environment



Where did you start


Docker


Yes, docker is a very cool thing, gaining popularity at a monstrous pace. Even found a few semi-finished products, such as bitnami-docker-symfony .


There is a premonition that you can deploy all the necessary environment on the docker, but two days of smoking the manuals did not lead to the result. If someone does a manual scan of the symfony environment when using docker that meets all the requirements outlined above, I will certainly point it out here.


The solution was incomprehensible in the first place for us, ready-made solutions did not meet the requirements, which means it did not fit.


Vagrant


We were able to deploy the environment on vagrant homestead. But the whole process of labor costs is akin to raising the web server from scratch with the only difference that you do not need to manually install some components, and therefore did not meet the principle of clarity for windows developer.


If you're interested, I’ll write a separate manual how to deploy symfony projects using vagrant. But I’ll say right away that this is also a work with a virtual machine, for some reason the symfony projects were not cached and it was a monstrously long load. Again, without changing app_dev.php, the debug mode was unavailable, because when the project was loaded on the local machine, in fact, a request was made to a web server that was running on a virtual machine. And yes, the database was also on virtual ...


Ironically, a simple decision came at the very end


Xammp


I wondered how all the same to deploy the environment for symfony projects is normal, because it is quite possible that in the end it will be easier and more correct. What the environment includes:



1. XAMMP - for php, mysql


In search of php installers for windows, I came across XAMPP , a php development environment. It contains all the necessary components (php, mysql, apache, phpmyqdmin and much more), is controlled from the graphical interface, includes the necessary services by a mouse click, is installed from a simple installer ("next", "next", "next" ...)


image

Php and mysql are all you need to debug a ready-made symfony project. We include mysql in xampp, from run.exe we run “php bin / console server: run” in the project directory, and that’s it, the site opens in the browser at localhost: 8000, and in debug mode without changing app_dev.php


Probably, the existence of xampp will not be news to many habravchan, but believe me, after all the atomic bombs in the face of dockers, wagrants, etc., which we threw on flies, it seemed like a miracle.


Things are small, you need git to interact with a remote repository, composer - to load the components of a symfony project locally and it's done.


2. Git - to communicate with the repository.


Git SCM is perfect for working with git - a set of useful nishtyakov:

git bash is a console that executes commands familiar to * nix users (including the generation of open rsa keys);
git GUI - a graphical interface for working with git;
Shell integrator that allows you to start the console in the desired directory by right clicking on the desired folder


If it is interesting, I can separately publish the manual for full git setup on windows, creating rsa keys, cloning remote repositories.


3. Composer - to install symfony components and libraries.


Put the composer, deploy the project

Any symfony project in addition to the actual project files contains thousands of library files and cache. Copying the entire directory of a deployed project from a remote server - history for 1-3 hours. That is why, by default, all components and cache are in .gitignore and are not transferred when repository is cloned.


To deploy all the necessary components you need composer . Swing, set. Now from the Git Bash terminal (and from the usual boring windows) you can run the composer.


Open the terminal in the symfony project directory, run the command:
composer install.


During installation, you will need to enter data related to access to the database, setting up your mail server, etc. You can specify the data immediately, then you can. In any case, without the composer install database, complete with a red swearing of console logs, but this should not be scary.


Configuring the database

You can create a database either from the command line or from phpmyadmin, which is included in xampp. We open xampp, we include mysql, apache, we select admin, near mysql. Phpmyadmin opens. How to create a database and a user in it, I think, no need to explain


The parameters of the new database and user must be entered in the symfony of the project (app / config / parameters.yml)


Next, the database must be aligned with the structure specified in the symfony project. To do this, in the project directory using Git Bash we sequentially execute several commands:


php bin/console doctrine:database:drop -- force php bin/console doctrine:database:create php bin/console doctrine:schema:update -- force php bin/console doctrine:schema:validate 

If there are no errors during these processes, you can start working on the project and debugging it.


We start the internal web server

In the project directory using Git Bash execute the command:


 php bin/console server:run 

In any favorite IDE, we connect to the symfony project on a local machine without having to synchronize files with a remote server.


In your favorite browser, open localhost: 8000 - open your symfony project, debug it immediately on your local machine, and in debug mode.


Let's commit all the changes and developments, push them to the server using your favorite Git GUI, or the one that was suggested above.


Summary


The symfony work environment is configured with minimal blood, works on the local machine, windows developer can start doing his own thing.


Perhaps there are other solutions, and with the same docker, and the solution with xampp does not have flaws, but it made it possible to quickly and simply deploy everything that is needed for work, and according to all the initial requirements.


If there are other, no less simple solutions, please in the comments.


')

Source: https://habr.com/ru/post/324304/


All Articles