DEV Community

Good-bye Docker, Hello Nix: Configuring a Magento 2 Development Environment with Rooter

Cristiano Pacheco on February 20, 2024

Table of Contents Introduction Requirements Creating a Magento 2 dev environment 1. Creating the project directory 2. Entering in th...
Collapse
 
jwater profile image
Jack • Edited

Hi

Thanks for the detailed explanation.

I came across this line and couldn't find any reference to this command in the Magento docs bin/magento config:data:import

Can you please explain what this does in your comment context ?.

Do you need to have composer installed globally or it does this in the project folder context when you run project create command ?

Thanks

Collapse
 
qixiano profile image
Cristiano Pacheco

Hello @jwater, very good question.

About the bin/magento config:data:import command,
it comes from semaio/magento2-configimportexport module.

That is an excellent module for exporting/importing the configurations to a yaml file.

Do you need to have composer installed globally or it does this in the project folder context when you run project create command ?

Everything you need to run the stack, including composer is already installed by devenv. Basically, when you enter the ~/Sites/magento2 folder, all the stack is loaded to the terminal context and available for usage out of the box. When you exit the ~/Sites/magento2 folder the stack is gone :)

Collapse
 
jwater profile image
Jack

Hi @qixiano

Thank you for getting back. Much appreciated.

So this module will have to be installed correct if you have to run this command ?.

It might be worth mentioning this in the guide.

May I kindly request to know, from what I understand this setup doesn't use docker or virtual machine ?

Thanks

Thread Thread
 
qixiano profile image
Cristiano Pacheco

Hello @jwater,

No, the semaio/magento2-configimportexport is required to be installed only if you run the rooter magento2:db-install command with --config-data-import option on it.

I'll mention it in the guide. Thank you for your suggestion.

May I kindly request to know, from what I understand this setup doesn't use docker or virtual machine?

You can still use Docker to run this setup if you want. However, it is not required at all. With Nix, the stack is installed natively on your machine.

Thread Thread
 
jwater profile image
Jack

Thanks @qixiano , got it.

Collapse
 
tomerbendavid profile image
Tomer Ben David

What is Magento? Does rooter supports java will it show in options?

Collapse
 
qixiano profile image
Cristiano Pacheco

Hello @tomerbendavid, Magento is an e-commerce platform.

Rooter does not support Java stack yet, but devenv supports it.

What is your current stack with Java? I mean what is the web server ( tomcat, wildfly, etc). Do you use some framework, such as spring boot?

Collapse
 
tomerbendavid profile image
Tomer Ben David

Jetty + Spring + Lombok. Works like a charm.

Collapse
 
mrovaiz profile image
Mohammed Rahil Ovaiz

Rooter is only for mac?
How can I do same setup of magento 2 in linux with nixos?
Please help me with this.

Collapse
 
qixiano profile image
Cristiano Pacheco

Hello @mrovaiz, Rooter only has support for macOS right now but will have support for Linux soon.

Collapse
 
jwater profile image
Jack

Hi @qixiano

I have been trying to setup a Magento project.

I have installed everything but when I run rooter magento2:db-install , I get the below.

Any help would be much appreciated.

rooter magento2:db-install

Dropping and recreating database

Removing app/etc/env.php

rm: app/etc/env.php: No such file or directory

In InstallMagento2DbCommand.php line 126:

  The command "rm app/etc/env.php" failed.                                

  Exit Code: 1(General error)                                             

Enter fullscreen mode Exit fullscreen mode
Collapse
 
jwater profile image
Jack • Edited

Hi @qixiano

So I manually created an empty env.php file in app/etc and run rooter magento2:db-install

Now I'm having issue with rabbitmq, see below

rooter magento2:db-install

Dropping and recreating database

Removing app/etc/env.php

Running magento setup:install

Could not connect to the Amqp Server.
Enter fullscreen mode Exit fullscreen mode

This is the setting it shows in the error message
--amqp-host=127.0.0.1 --amqp-port=5732 --amqp-user=guest --amqp-password=guest --amqp-virtualhost="/" \

When I do the status, it gets stuck like this (attached)

Appreciate any help.

Thanks

Image description

Collapse
 
qixiano profile image
Cristiano Pacheco

Hello @jwater, it seems your env is not running. Just try to start it and try again.

Thread Thread
 
jwater profile image
Jack

Hi @qixiano

I did, but noticed the stop sometimes doesn't work as it errors due to one port staying in use.

Anyway, I managed to finally setup another project and the rabbitmq initially started but then after some time crashed.

I created another new project not knowing how to restart rabbitmq service only and rabbitmq crashed immediately when I ran rooter env:start --debug

I have opened a ticket here with the error details github.com/run-as-root/rooter/issu...

If you know how I can try to restart rabbitmq or any other advice, would be helpful.

Thanks

Collapse
 
jwater profile image
Jack

Hi @qixiano

I wanted to ask how would I got setting up cron if I have more than one magento 2 environment ?.

Would it look something similar like below in my crontab crontab -l ?

#~ MAGENTO START c5f9e5ed71cceaabc4d4fd9b3e827a2b

* * * * * /nix/store/env-1-hash-devenv-profile/bin/php /path/to/magento-env-1/bin/magento cron:run 2>&1 | grep -v "Ran jobs by schedule" >> path/to/magento-env-1/var/log/magento.cron.log

* * * * * /nix/store/env-2-hash-devenv-profile/bin/php /path/to/magento-env-2/bin/magento cron:run 2>&1 | grep -v "Ran jobs by schedule" >> path/to/magento-env-2/var/log/magento.cron.log

#~ MAGENTO END c5f9e5ed71cceaabc4d4fd9b3e827a2b
Enter fullscreen mode Exit fullscreen mode

Thanks