Use m2c toolset for existing project
Could you give me an instruction step by step how to use this tool with existing project? I'm trying and trying and even if I copy .env file to the new project, than create src and there git clone of the existing project - after m2c init a new magento project is added.
Edit:
I have just checked repo docker-magento-mutagen and there is this flag:
--magento-project=<path>
Can I use similar flag for m2c?
Thank you in advance
Hey @webphpprojects,
Prepare your existing project files and database dump SQL file.
Run m2c init command inside of that project root directory.
Configure your dev environment by answering a questionnaire and after that, the m2c tool will detect your existing Magento project and ask you to import the existing database, in that step you will need to provide a path to database dump SQL file. After that toolset will create required Docker containers and import database.
Maybe it's my fault, but it doesn't work as You desrcibed. I will describe step by step what I did:
- git clone of my existing project
- m2c init - inside project
- I have this:
Scanning current directory................................................... ✔
Project .env file is not found, starting interactive setup
- Set the domain name for your project: I chose project.test. - it's fine for me
[Configure sources path]
Set sub-directory for Magento installation? [n]
- Next step is to choose environment:
[Configure environment]
Set Nginx version for your project: [1.17]
Set PHP version for your project: [7.2]
Set MariaDB version for your project: [10.3]
Set Redis version for your project: [5.0]
[Configure environment extras]
Include Varnish service? [n]
Include Elasticsearch service? [n]
Include RabbitMQ service? [n]
Include phpMyAdmin service? [n]
- Finally, last step is to set magento version and include or not sample data - but it's rather for new project
[Configure Magento installation]
Set Magento version for your project: [2.3.4]
Include Magento sample data? [n]
[Configure Composer auth]
Authentication is required for Composer repository repo.magento.com
Use authentication information from the current composer config? [y]
In next step m2c downloads magento to the folder Where is missing that I can't do it as You described?
It should be like this
...
[Configure environment extras]
Include Varnish service? [n]
Include Elasticsearch service? [n]
Include RabbitMQ service? [n]
Include phpMyAdmin service? [n]
[Configure Magento installation]
Checking Magento source files................................................ ✔
Detected Magento: v2.3.3
Admin url path: admin
[Configure Composer auth]
Authentication is required for Composer repository repo.magento.com
Use authentication information from the current composer config? [y]
[Configure Database]
Import existing database? [y]
Specify full path to plain sql or gzipped database dump file to import.
...
Make sure that your existing project has files pub/index.php, composer.json, and app/etc/env.php. m2c uses these files to detect Magento version and admin path.
You're right - my project doesn't have pub/index.php and env.php :) (as I know it will be created during di:compile) I fixed it by added both files
Now I have other issue:
[Cleanup]
Cleanup before creating containers........................................... ✔
ERROR: .FileNotFoundError: [Errno 2] No such file or directory: './.m2c/docker/docker-compose.yml'
[Creating docker container]
[Push]
Pushing all files to php docker container.................................... ✘
Error: No such container:path: project.test__php:/var/www
How can I fix it?
Edit:
Even if I did m2c down and m2c init I have same error ;/
How can I fix it?
Run m2c update
Even if I did m2c down and m2c init I have same error ;/
Try m2c down and also try to remove .m2c directory and .env file from magento project root to run fresh with m2c init command.
Ok, It helped me :) I have, I hope last problem. If I open project.test in my browser I have 404 not found. How can I detect this issue?
Make sure that m2c.test_* toolset service containers and your project project.test_* containers are running.
Open https://portainer.m2c.test to check the project's nginx logs.
Also, check nginx.conf file in project root - it should have $fastcgi_backend entries, but not fastcgi_backend (notice $ symbol).
I have only nginxi.conf.sample and in log I see this line - for nginx container:
2020/04/14 18:39:26 [error] 11#11: *6 "/etc/nginx/html/index.html" is not found (2: No such file or directory), client: 192.168.96.3, server: , request: "GET / HTTP/1.1", host: "project.test"
Should I rebuild my project?
Edit:
I did m2c down and removed project than git clone and m2c init and it works now :)
Thank you for Your support and help
Nice!
Also, it was possible to configure nginx.conf with command:
sed -e 's/fastcgi_backend/$fastcgi_backend/g' nginx.conf.sample > nginx.conf
Push it to the container and restart:
m2c push nginx.conf && m2c restart nginx
I am 99% sure that I forgot do a database dump SQL file from my project. Can it work without this dump ? I've tried use my existing project and have error: "In Mysql.php line 110:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'magento.flag' do
esn't exist, query was: SELECT flag.* FROM flag WHERE (flag.flag_cod e='config_hash')
In Mysql.php line 91:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'magento.flag' do
esn't exist
config:set [--scope SCOPE] [--scope-code SCOPE-CODE] [-e|--lock-env] [-c|--lock-config] [-l|--lock] [--] 