AWS: how to get a number of files in S3 bucket

If you’re regularly using AWS S3, you might have wondered how to count the number of files in a bucket.

Technically, getting the files count information for a S3 bucket is easy and straightforward. Read on as we demonstrate some ways to accomplish this.

1. Using AWS Metrics section

  1. Go to AWS S3 Console
  2. Select a bucket to get the number of files
  3. Go to the Metrics section
  1. Get the number from the “Total number of objects” metric

2. AWS CLI

Also, you can use next AWS CLI commands:

aws s3 ls s3://your-s3-bucket/ --recursive | ws -l

>> 80

or

aws s3 ls s3://your-s3-bucket/ --recursive --summarize | grep "Total Objects:"

>> Total Objects: 80

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