Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use m2c toolset for existing project #37

Open
webphpprojects opened this issue Apr 14, 2020 · 10 comments
Open

Use m2c toolset for existing project #37

webphpprojects opened this issue Apr 14, 2020 · 10 comments

Comments

@webphpprojects
Copy link

webphpprojects commented Apr 14, 2020

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

@shkoliar
Copy link
Member

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.

@webphpprojects
Copy link
Author

webphpprojects commented Apr 14, 2020

Maybe it's my fault, but it doesn't work as You desrcibed. I will describe step by step what I did:

  1. git clone of my existing project
  2. m2c init - inside project
  3. I have this:
Scanning current directory................................................... ✔

Project .env file is not found, starting interactive setup
  1. 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]
  1. 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]
  1. 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?

@shkoliar
Copy link
Member

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.

@webphpprojects
Copy link
Author

webphpprojects commented Apr 14, 2020

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 ;/

@shkoliar
Copy link
Member

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.

@webphpprojects
Copy link
Author

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?

@shkoliar
Copy link
Member

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).

@webphpprojects
Copy link
Author

webphpprojects commented Apr 14, 2020

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

@shkoliar
Copy link
Member

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

@maya5510
Copy link

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] [--]
"
Zrzut ekranu z 2021-04-14 19-38-44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants