Magento 2 installation: Access denied for user root@localhost

If you get the following error during magento 2 installation:
Access denied for user root@localhost

magento2$ php bin/magento setup:install
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO)
User Name is a required field.
First Name is a required field.
Last Name is a required field.
Please enter a valid email.
Password is required field.
Your password must be at least 7 characters.
Your password must include both numeric and alphabetic characters.

Continue reading

Magento 2 installation: PHP Fatal error Allowed memory size exhausted

A frequent problem during Magento 2 installation (using php bin/magento setup:install ) is a site running out of memory and generating an error like this – “PHP Fatal error: Allowed memory size of NNN bytes exhausted”. This fatal error means that your hosting or local machine is not able to provide enough memory for the installation script to run correctly.

Allowed memory size exhausted

There are full error and php stack trace:

$ php bin/magento setup:install --admin-firstname name \
 --admin-lastname lastname --admin-email=email@email.com
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 5 bytes)
 in magento2/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php
on line 228

Continue reading

How to build a hello world module for Magento

Create your first “Hello World” magento module with the following steps.

  1. Create a folder structure for your module:
    • app/code/local/{ModuleNamespace},
    • app/code/local/{ModuleNamespace}/{ModuleName}
    • app/code/local/{ModuleNamespace}/{ModuleName}/etc
    • app/code/local/{ModuleNamespace}/{ModuleName}/controllers
  2. Configure your module: create a config.xml file in app/code/local/{ModuleNamespace}/{ModuleName}/etc/ directory
  3. Create a controller file IndexController.php in your controllers directory
  4. Activate your module: create a {ModuleNamespace}_{ModuleName}.xml file in app/etc/modules/
  5. Clear the Magento cache
  6. Visit http://domain.com/yourUrl

Right now, we will explore these steps in details:

Continue reading