phpmagento2development-environment

How to get running on a local dev environment from an existing and complex Magento2 project


At work we took back our existing store running on Magento 2 from an external development agency. I need to get the project running in local development (with docker).

I familiarized myself with a vanilla project from the official docs and managed to get it running by downloading the vanilla template with composer, granting the proper permissions on files and folder and running the magento setup:install command.

My question is how do one goes when kick starting from an existing (production running) project?

  1. Do I need to run setup:install again? If I do, why?
  2. What do I need to import from production to ensure any content or configuration created via the admin is also running on my local setup? Should I import the complete Database from production?
  3. I know our setup is using more than just php and mysql, but env.php seems to be listing only db configuration and admin url. Where can I get the complete service configuration informations about what our setup uses?
  4. Anything else I am missing to get started with an existing project for local development?

Solution

  • As someone who is running Magento 2 on a local environment myself, hopefully I can shed some light on this.

    1. If you have a direct copy of the live site, you do not need to run setup:install again.

    2. Ensure you have a copy of the entire Magento 2 site (you can technically ignore the vendor folder, as you can run composer install and it will redownload those files, but that's up to you). Also get a copy of the entire database. Magento 2 is notorious for copying the same data to multiple tables so something could break if you don't have everything.

    3. What do you mean by "service configurations" If you are referring to Magento 2 extensions, that data is saved in the database, not the env.php file. env.php is only for server side configurations, such as the DB information, Caching, and things of that nature. On mine, I use Redis for site Cache, so that would be included in that file as well, as an example.

    4. When you first unpack the site to your local environment, run composer update in the directory. This will ensure you have all the proper files installed. If you are going to run a local dev environment, set the mode to development with the following command: bin/magento deploy:mode:set developer. This will allow you to make changes and to view those changes by just refreshing the page, rather than flushing cache all the time.