Sylius installation doesn't work - php

I have a problem with the installation of Sylius.
PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 32 bytes) in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/DependencyResolver/RuleSetGenerator.php on line 126
This error occur when I run : composer create-project -s dev sylius/sylius-standard Club26
My configuration is :
Wamp on Win7 64bits (for Apache, PHP and MySQL)
I have git installed
I use cmder to run my command
I have changed memory_limit = 1024M in php.ini
I tried with composer install with Windows Setup, and with composer.phar
Thanks for help

Try disabling Garbage Collection during installation.
For global installations of Composer
$ php -d zend.enable_gc=0 `which composer` create-project -s dev sylius/sylius-standard Club26
For local installation of composer.phar
$ php -d zend.enable_gc=0 composer.phar create-project -s dev sylius/sylius-standard Club26

Just in case, I got also memory error during the execution of sylius:install
I set memory_limit to -1 to fix it
$ php -d memory_limit=-1 app/console sylius:install

Related

Installing memcached on Amazon Linux

I am trying to use memcached for PHP on a Amazon Linux EC2 instance. In my PHP script when I call $mc = new Memcached(); the following error gets thrown in /var/log/php-fpm/www-error.log:
[06-Sep-2020 00:49:44 UTC] PHP Fatal error: Uncaught Error: Class 'Memcached' not found in /var/app/current/memcached.php:8
Stack trace: #0 {main}
thrown in /var/app/current/memcached.php on line 8
Calling php -m I do not see memcached listed, which I assume means it is not installed.
So, first I tried:
sudo yum install memcached
sudo yum install php70-pecl-memcached
along with edits to /etc/php.ini to include
session.save_handler = memcached
session.save_path = "127.0.0.1:11211"
as outlined here but no luck.
So next, I tried the suggestion as outlined by AWS support here for Amazon Linux EC2 v1. Looking through cfn-init-cmd.log, the package libmemcached is installed successfull, however, the script fails when it tries to install memcached as it is unable to find /use/bin/pecl7 as per the command 01_install_memcached. For reference, my full script in .ebextensions/memcache.config was:
packages:
yum:
libmemcached-devel: []
commands:
01_install_memcached:
command: /usr/bin/yes 'no'| /usr/bin/pecl7 install memcached
test: '! /usr/bin/pecl info memcached'
02_rmfromphpini:
command: /bin/sed -i -e '/extension="memcached.so"/d' /etc/php.ini
03_createconf:
command: /bin/echo 'extension="memcached.so"' > /etc/php-7.3.d/41-memcached.ini
test: '/usr/bin/pecl7 info memcached'
Any ideas on how to resolve?
So this slightly revised .ebextension script worked. I'm no AWS/Linux/PHP expert, so there is probably a more correct way to approach this.
packages:
yum:
libmemcached-devel: []
commands:
01_install_memcached:
command: /usr/bin/yes 'no'| /usr/bin/pecl install memcached
test: '! /usr/bin/pecl info memcached'
02_rmfromphpini:
command: /bin/sed -i -e '/extension="memcached.so"/d' /etc/php.ini
03_createconf:
command: /bin/echo 'extension="memcached.so"' > /etc/php.d/41-memcached.ini
I solved this by adding memchache directly into installation
packages:
yum:
libmemcached-devel: []
memcached
commands:
01_rmfromphpini:
command: /bin/sed -i -e '/extension="memcached.so"/d' /etc/php.ini
02_createconf:
command: /bin/echo 'extension="memcached.so"' > /etc/php.d/41-memcached.ini

Unable to run Laravel Composer Update - RAM and Swap file limitation - VPS

I recently subscribed to hostinger vps with 1GB ram. But i cannot run composer update.
[ErrorException]
proc_open(): fork failed - Cannot allocate memory
The problem is i cannot run composer update because of the RAM limitation. I tried setting the ram limit to 512m to 768m to -1 but it still doesnt work. I still get the RAM error Issue.
php -d memory_limit=512M /usr/local/bin/composer update
php -d memory_limit=768M /usr/local/bin/composer update
php -d memory_limit=-1 /usr/local/bin/composer update
I also tried the swap file but unfortunately, hostinger doesn't allow swap files. i cannot use the swapon command.
swapon: /swapfile: swapon failed: Operation not permitted
I am looking for help on the options so that I can run a laravel project on the vps with 1GB ram.
I tried all the suggestions on the docs but none helped.
https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors
I am really in a bind here. Any help is greatly appreciated.
As pointed out by #apokryfos , running
composer update
on the development machine then committing the updated composer.lock file and then running
composer install
on the live server resolved the problem.
Thanks to all who answered.

OSX composer increase memory limit

I am having memory issues with composer; trying to increase the available amount above 128MO. I have been following the guidelines from composer.org but nothing seems to work.
If I locate php.ini on my machine I get:
/Applications/MAMP_2018-08-02_14-10-44/conf/php7.1.6/php.ini
/Library/Application Support/appsolute/MAMP PRO/conf/php.ini
/private/etc/php.ini.default
/private/etc/php.ini.default-previous
I sudo /private/etc/php.ini.default and change MEMORY_LIMIT = 512MO
but when I do php -r "echo ini_get('memory_limit').PHP_EOL;" I still get 128 MO
now I try php -d memory_limit=-1 composer.phar but I get Could not open input file: composer.phar
locate composer.phar returns nothing....
What am I missing please ?
To run composer with no memory limit, first find out where your composer binary is with which composer. Use the resulting path like so:
php -d memory_limit=-1 /usr/local/bin/composer require etc/etc
You could also alias this: alias composer="php -d memory_limit=-1 /usr/local/bin/composer", which would allow you to call composer as you would normally.
Add that line to your bash profile if you want to use composer without limits permanently.
To have no memory limit, set this directive to -1
php -d memory_limit=-1 which composer install

Php Fatal error: momory size exhausted when using composer to install user-bundle

When triing to install FOSuserbundle with composer I got the following message in the Terminal:
"PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 79 bytes) in phar:///Users/myname/MyWebSite/composer.phar/src/Composer/ DependencyResolver/Solver.php on line 177"
How can I fix it?
EDIT / FURTHER INFORMATION
In Terminal typing: php -r "echo ini_get('memory_limit').PHP_EOL;"
get me the following: 128M
while php.ini (App/MAMP/conf/php5.4.4/php.ini) has the following line: memory_limit = 32M
why different value?
how can I change the value so that composer can install the bundle?
I tried the following in terminal but got an error: php -d memory_limit=512M composer.phar/src/Composer/DependencyResolver/Solver.php
error ==> Could not open input file: composer.phar/src/Composer/DependencyResolver/Solver.php
I've solved this in the past by using simply:
php -d memory_limit=1G /usr/local/bin/composer update --prefer-dist --no-dev
Where the no-dev may help reduce the memory footprint too - certainly speed.
Composer should be run with at least 1 GB of allowed and available memory. If your machine has less memory physically installed, you should consider upgrading or using a different machine - otherwise the process will start swapping and taking huge amounts of time, so something that should be done in less than a minute will take days.
If you are unable to raise the memory limit for PHP, you are out of luck unfortunately. Composer needs some huge data structures when updating.

Composer killed while updating

I got a problem, I tried to install a new package to my Laravel 4 project.
But when I run php composer.phar update I get this:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Killed
I have looked for the problem in the Internet and saw that the memory is the problem, I think I don't have enough RAM available, I've checked this I have about 411mb free.
Does composer really need more RAM?
The "Killed" message usually means your process consumed too much memory, so you may simply need to add more memory to your system if possible. At the time of writing this answer, I've had to increase my virtual machine's memory to at least 768MB in order to get composer update to work in some situations.
However, if you're doing this on a live server, you shouldn't be using composer update at all. What you should instead do is:
Run composer update in a local environment (such as directly on your physical laptop/desktop, or a docker container/VM running on your laptop/desktop) where memory limitations shouldn't be as severe.
Upload or git push the composer.lock file.
Run composer install on the live server.
composer install will then read from the .lock file, fetching the exact same versions every time rather than finding the latest versions of every package. This makes your app less likely to break, and composer uses less memory.
Read more here: https://getcomposer.org/doc/01-basic-usage.md#installing-with-composer-lock
Alternatively, you can upload the entire vendor directory to the server, bypassing the need to run composer install at all, but then you should run composer dump-autoload --optimize.
If like me, you are using some micro VM lacking of memory, creating a swap file does the trick:
#Check free memory before
free -m
mkdir -p /var/_swap_
cd /var/_swap_
#Here, 2G ~ 2GB of swap memory. Feel free to add MORE
sudo fallocate -l 2G swapfile
chmod 600 swapfile
mkswap swapfile
swapon swapfile
#Automatically mount this swap partition at startup
echo "/var/_swap_/swapfile none swap sw 0 0" >> /etc/fstab
#Check free memory after
free -m
As several comments pointed out, don't forget to add sudo if you don't work as root.
btw, feel free to select another location/filename/size for the file.
/var is probably not the best place, but I don't know which place would be, and rarely care since tiny servers are mostly used for testing purposes.
Unfortuantely composer requires a lot of RAM & processing power. Here are a few things that I did, which combined, made the process bearable. This was on my cloud playpen env.
You may be simply running out of RAM. Enable swap: https://www.digitalocean.com/community/search?q=add+swap (note: I think best practice is to add a seperate partition. Digitalocean's guide is appropriate for their environment)
service mysql stop (kill your DB/mem-hog services to free some RAM - don't forget to start it again!)
use a secondary terminal session running top to watch memory/swap consumption until process is complete.
composer.phar update --prefer-dist -vvv (verbose output [still hangs at some points when working] and use distro zip files). Maybe try a --dry-run too?
Composer is apparently know to run slower in older versions of PHP (e.g. 5.3x). It was still slow in 5.5.9 for me...
DigitalOcean fix that does not require extra memory - activating swap, here is an example for 1gb:
in terminal run below
/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
/sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1
The above solution will work until the next reboot, after that the swap would have to be reactivated. To persist it between the reboots add the swap file to fstab:
sudo nano /etc/fstab
open the above file add add below line to the file
/var/swap.1 swap swap sw 0 0
now restart the server. Composer require works fine.
I've got this error when I ran composer install inside my PHP DOCKER container,
It's a memory issue.
Solved by increasing SWAP memory in DOCKER PREFERENCES from 512MB to 1.5GB
To do that:
Docker -> Preferences -> Rousources
Increase the memory limit for composer
php -d memory_limit=4G /usr/local/bin/composer update
Run composer self-update and composer clearcache
remove vendor and composer.lock
restart your local environment and then run
php -d memory_limit=-1 /usr/local/bin/composer install
If you're using docker you can use COMPOSER_PROCESS_TIMEOUT
environment:
COMPOSER_MEMORY_LIMIT: -1
COMPOSER_PROCESS_TIMEOUT: 2000 #seconds
Also in big projects composer needs more RAM than 2GB, you can check that with ps -aux while it is running.
You will have to add it manually inside docker options, nothing else will help.
Here's how I succeeded in installing maatwebsite\excel package from composer in Laravel Framework:
I download composer.json file and composer.lock file from my remote server.
I run composer update from local command prompt (then wait until all the install process finished).
Upload composer.lock file to remote server.
run composer install on remote server (then wait until all process finished).
DONE
composer 2 update have reduced the memory usage
composer self-update
composer update
composer require xxx
Fix for AWS ec2 Ubuntu Server Php Memory Value Upgrade For Magento 2.3.X
Php 7.2 / 7.3
nginx
ubuntu
composer 1.X
mariaDB
magento 2.3.X
Error : Updating dependencies (including require-dev)
Killed
for
Ram Must at least 4GB
Change instance type to suitable or Upgrade Ram
Php Memory Value change
Server Restart
Try to install the same package again
PHP value update
may locate under '/etc/php/7.2/fpm/php.ini'
depend on your server and PHP fpm X.XX version
Using Seed command 'change as your server requires'
on my case >> /etc/php/7.2/fpm/php.ini
memory limit type as "3.5G" or "3500MB"
Php 7.2.X
sudo sed -i "s/memory_limit = .*/memory_limit = 3.5G/" /etc/php/7.2/fpm/php.ini
Php 7.3.X
sudo sed -i "s/memory_limit = .*/memory_limit = 3.5G/" /etc/php/7.3/fpm/php.ini
Test if applied on 'free -h' command
free -h
Install-Package Again#
Install extension via Composer
go to your Magento 2 installation directory
cd /var/www/html/
with 'superuser' privileges
sudo su
Start installation
composer require XXXXXX/XXXXXXX
Enable Module s
php bin/magento module:enable XXXXXX/XXXXXXX
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
Restart
sudo reboot
Enjioy
I was facing this same issue on my ec2 instance, following steps worked for me :
Copied composer.lock file from my local environment to ec2.
then run sudo composer install and its simply installed all the dependencies for my project.
I solved it maintaining the below steps in my ubuntu server. Hope it will works for you.
Stop my apache server
sudo service apache2 stop
Run composer update
sudo composer update
Start my apache server
sudo service apache2 start
php -d memory_limit=5G composer.phar update
I get this problem caused for a package that don't update correctly with wildcards, I use directly the last version and it works finally.
"l3/cas-bundle": "~1.0" -------> "l3/cas-bundle": "1.1.13"
Solved on Laravel/Homestead (Vagrant Windows)
Edit Homestead.yaml and increase memory from 2048 to 4096
vagrant up
vagrant ssh
Install Symfony with this line on the folder you choose (must be without files)
COMPOSER_MEMORY_LIMIT=-1 composer create-project symfony/website-skeleton . -s dev
I was using:
Virtualbox
4096 Gb RAM
2 CPU
10 GB HDD (500 MB swap)
Ubuntu 20.04
Running:
composer update in a laravel 8 project folder
I didn't set the swap for the virtual machine, so Virtualbox created a 500Mb swap space, which was NOT enough.
So composer was using 4Gb of RAM plus swap.
I gave more swap space to the VM and then it worked.
As the picture below, composer used all my RAM + 2GB of swap
System Monitor
You can try setting preferred-install to "dist" in Composer config.
I was getting this error in a local Docker environment. I solved it by simply restarting Docker.

Categories