⬆️ ⬇️

Synchronization of the web developer workspace





Good day, Habr!



Recently, I was puzzled by the synchronization of the workspace among all the computers I used. I realized that dragging all the files and databases of the site from one computer to another is not an option. Having decided to automate this process, I paid attention to Dropbox \ Google Drive \ Yandex.Disk \ any other cloud drive (choose your own version).



First of all, I thought about GIT (bitbucket, github), but it's very difficult to synchronize databases with it. Moreover, I wanted a fully automatic solution. Therefore, this option has disappeared.

')

For a start, I decided to look for a service that would perform all the necessary actions for me, including:







After spending a couple of hours searching, I did not find anything suitable. But in the process I came across a lot of instructions and guides to synchronize the workspace through Dropbox and the like. Having found no other way, I also decided to try this solution.



Unfortunately, not a single article had exhaustive instructions on all points of interest to me. Also, in the process I came across with a considerable number of problems that were not at all covered.



First of all, it was necessary to determine the stack of tools. I used the Denver package for developing for Windows and MAMP to work on Mac OSX. Unfortunately, these tools are poorly compatible, and I decided to look for an alternative to them. I wanted to find a cross-platform solution that would rule out a version conflict. Initially, I planned to use XAMPP, but I had problems when trying to configure it.



image



After a brief search, I stumbled upon AMPPS



Benefits:



I decided to try this package, and it turned out to be perhaps the best solution. Now I have completely switched to it.



Now it was necessary to configure this software to store all files in the directory of the cloud drive. The task was not as trivial as it might seem.



image



You need to go to the Apache section, and select the Configuration item. A configuration file will open in which we need to find and change the line



# DocumentRoot: The directory out of which you will serve your # documents. By default, all requests are taken from this directory, but # symbolic links and aliases may be used to point to other locations. # DocumentRoot "D:\\ \ " 


The next step is to synchronize the database. Here were the most problems and conflicts. In order to use synchronization, you need to change the configuration. Go to the panel, click MySQL and select the configuration item. Next, look for and change the line:



 # Replication Master Server (default) # binary logging is required for replication #log-bin=mysql-bin 


It is necessary to comment out MySQL logging, since because of it there were failures and conflicts. Next you need to synchronize the bases themselves. To do this, we go to the folder AMPPS \ mysql. You need to make a symbolic link to the data folder and link it to a folder in the cloud drive. To do this, open the console:



For the first Windows machine:



 cd “C:\\\AMPPS\mysql” mkdir "D:\\\\\mysql" mv data “D:\\\ \Sublime\User” cmd /c mklink /D data "D:\\\\\mysql\data" 




For each subsequent, Windows:



 cd "C:\\\AMPPS\mysql\" rmdir -recurse data cmd /c mklink /D data "D:\\\\\mysql\data\" 




For the first MacOSX machine:



 cd ~/Application/AMPPS/mysql/ mkdir ~// / /mysql/ mv data ~// / /mysql/ ln -s // /  data 




For each subsequent machine, MacOSX:



 cd ~/Application/AMPPS/mysql/ rm -r data ln -s // /  data 




Now your databases are synchronized. To create a new site, you need to go to the web-control panel, the address is localhost / ampps . Further to the Add domain section. The main thing that you need to fill in correctly in this section is the Domain path. Specify here a folder in the cloud drive, created in the same directory where DocumentRoot Apache was registered. This procedure must be done for each machine. After that you will have a fully synchronous project available.



The last point, I wanted to synchronize projects, settings and plugins for my favorite IDE Sublime text. At the moment I am using version 3. For proper synchronization, you only need to synchronize the Packages / User folder, since for each OS, there may be its own version of the plugin. In this case, the list of plug-ins will be synchronized (you need to install the Package Control in advance), and the correct version will be downloaded automatically.



For the first Windows machine:



 cd "$env:appdata\Sublime Text 3\Packages\" mkdir “D:\\\ \Sublime” mv User “D:\\\ \Sublime\User” cmd /c mklink /D User “D:\\\ \Sublime\User” 




For each subsequent Windows machine:



 cd "$env:appdata\Sublime Text 3\Packages\" rmdir -recurse User cmd /c mklink /D User “D:\\\ \Sublime\User” 




For the first MacOSX machine:



 cd ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/ mkdir ~// / /Sublime mv User ~// / /Sublime ln -s ~// / /Sublime/User 




For each subsequent machine, MacOSX:



 cd ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/ rm -r User ln -s ~// / /Sublime/User 




Obviously, you can also save projects in this folder. Now the synchronization of the workspace is complete.



Before writing this post, I tested this synchronization method. Were written 3 projects, from beginning to end. Only once did the database fail and there was no significant data loss. With a 90% chance this was due to my cant in the code. The speed and convenience of synchronization covers all the hassle with customization and allows you to significantly improve the flow of work.

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



All Articles