Fresh Laravel install giving Mcrypt "error". (OSX) - php

I install laravel by running:
laravel new testing
And it responds with:
Application ready! Build something amazing.
Yet when I visit public/index.php, it presents an empty page that says:
Mcrypt PHP extension required.
When I run php -m it does not list Mcrypt.
I tried installing it with composer, by running:
composer create-project laravel/laravel laravel_composer --prefer-dist
And it resulted with the following:
Writing lock file
Generating autoload files
Mcrypt PHP extension required.
Script php artisan clear-compiled handling the post-install-cmd event returned with an error
[RuntimeException]
Error Output:
There is nothing additional after "Error Output:"

Solution by OP.
I resolved the issue by updating to php55 and php55-mcrypt using homebrew.
I had an issue with conflicting php versions post-install, which I resolved by editing the apache2 httpd.conf property LoadModule php5_module. By uncommenting it and changing the default file path to look for local/php5-5.5.11-20140408-141340/libphp5.so.
Mcrypt was no longer an issue and apache was locating the correct php. The last thing I had to do was change the permissions of laravel_project/app/storage using chmod -R o+w storage

Related

Laravel composer install giving error "Your lock file does not contain a compatible set of packages please run composer update"

I have been writing laravel code for quite sometime. Currently, I tried cloning a project from github and editing locally. I installed composer in my project directory but a vendor folder was not included, I tried to run composer install but I gives me this error
Your lock file does not contain a compatible set of packages. Please run composer update
How do I resolve this?
Note: I have tried running composer update on previous clones and that didn't work.
Run this command:
composer install --ignore-platform-reqs
or
composer update --ignore-platform-reqs
Disclaimer, this solution will not fix the issue for PHP 8 projects.
In most cases this happens because of PHP 8 (In my case it was GitHub CI actions automatically started using PHP 8 even though my project is php 7.4)
If you have multiple PHP installations (E.g. 7.4 and 8 on the same server), this is how you can fix it.
Specify your php version in your composer.json file
"config": {
"platform": {
"php": "7.3"
}
},
If you have the lock file already committed, run composer update after you adding above line in to the composer.json and then commit the new lock file. (Please be aware composer update will upgrade your packages to latest versions)
I solved this problem with this command:
composer self-update --1
It probably works because at time that the project was developed, composer was on another version and when change the Major version from 1 to 2 the compatibility was broke. With this command you downgrade composer and probably going to solve this
You should try running composer update --lock that will update all packages and recreate the compose.lock file.
Either you can delete the composer.lock file and run composer install that will also recreate the .lock file.
This resolved my issue.
I had this error with Github Actions trying to deploy a Laravel app, this is probably different than the OP's case but none of the suggestions worked for me. Adding my answer here just in case there is someone else out there with a similar problem to mine.
I had to disable -q in Github Actions and see that it was complaining about extensions not being installed.
Make sure your require section of composer's php extensions matches the extensions: in your github action file for shivammathur/setup-php#v2 and it will deploy again
Recently I've just come across of this error when I tried to run my Laravel 7 project which required php v7.* with php v8. As I forgot my php version I just tried bunch of composer command, but just got error after error.
Anyway, to solve this just downgrade/upgrade php version as required. Just search how to do that in youtube.
you can see your project required php version in composer.json file (just if you wonder)
Also you can try following way (But though it didn't worked for me, seems it helped quite some people)
-- Open composer.json file and change php version to something like this: "php": "^7.3|^8.1"
-- Then run composer update
I faced this problem with my cakephp project in garuda linux (arch based)
Fix :
Install php-intl using sudo pacman -S php-intl
Enable php intl by editing php config ( in my case /etc/php/php.ini ) .
add extension=intl or uncomment the existing one
restart apache or whatever you are using
I had the same error deploying another project with composer, but the problem was a missing php extension.
I understand you solve your problem but for anyone seeing the same error message, here is a general guidance :
The error message Your lock file does not contain a compatible set of packages. Please run composer update is shown each time there is a conflict during the dependency solving step of composer install. (see the relevant part in composer source code)
It doesn't inform on the real problem though, and it could be hard to guess.
To get the exact explanation you can add --verbose option to composer install command (the option is available to any composer command (see the doc)) : composer install --verbose
It will give you the full message explaining what exactly is preventing composer install from completing (package version conflict, missing php extension, etc.), then you'll be able to fix the problem.
Hope this could help.
In my case this problem is occuring in Ubuntu 20.04 Desktop. This is due to some missing packages.
I ran the following commands to install some packages then rerun Composer install and its working properly. The commands are:
sudo apt-get install php-mbstring
sudo apt-get install php-xml
Then rerun composer install

Not able to install symfony on windows

Hello I am trying to install symfony on Windows. I had follow the all require steps for it but it end up with below message.
[RuntimeException]
Symfony can't be installed because the downloaded package is corrupted.
To solve this issue, try executing this command again:
Symfony new demo 3.2.8
When i tried above command it says :
'symfony' is not recognized as an internal or external command,
operable program or batch file.
I have try to reinstall composer and Symfony package both but it does not resolve the issue. It stays the same issue again.
Please help me how can I install it on Windows.
You are required to make it run through PHP as its a script file.
This gets the installer (which it looks like you have already)
php -r "readfile('https://symfony.com/installer');" > symfony
Then php symfony new demo 3.2.8 (asuming if php is in path otherwise you have to specify the php.exe path too)
For the full details see http://symfony.com/doc/current/setup.html
Regards
forget about that installer use composer from command line
composer create-project symfony/framework-standard-edition my_project_name
BTW i don't know what server you are using (wamp/xamp etc), i recomending this
https://laragon.org/
it have composer and all tools that you need to start with symfony

artisan clear-compiled return error code 255

When runnning composer install on my laravel project I get the error:
Script php artisan clear-compiled handling the post-install-cmd event returned with error code 255
Any advice on what could be the issue? Note composer installs all the vendor packages. The full output is below:
[user#some_path]$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
> php artisan clear-compiled
Script php artisan clear-compiled handling the post-update-cmd event returned with error code 255
Makse sure your storage/ & bootstrap/cache directory writeable.
Make sure your .env file doesent contain any spaces.
Ex:
key=value istead of key=va lue
remove the
bootstrap/cache/config.php file.
then
composer dumpautoload
composer update
Try to remove /bootstrap/compiled.php ( if you have it )
step 1 - Check your php version. If your laravel is old , then it wont support 7.x, you need to switch (check this if you are using mac) to PHP 5.6 in this case.
Step 2 - remove composer.lock and run composer install
The only thing that command does is delete the bootstrap/cache/services.php file, if it exists. Most likely, the file exists, but the permissions aren't set correctly to allow you to delete it.
i found the solution. Here is list of extensions that causes this problem.
extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
extension=php_pgsql.dll
extension=php_pdo_mysql.dll
you have to uncomment all of these extensions from your php.ini
E:\wamp64\bin\php\php7.1.9\php.ini
Note :: Must check your database credential into your .env file
I assume the problem can come from multiple sources. In my case, I had a syntax error in my config/app.php. Reverted to a previous version and the remade my edits.
Just run the npm install command from any terminal then re-run composer to install all your dependencies.

Getting error during use of composer installation on windows

I have executed the following command on windows command prompt
folder path >php composer.phar install
Getting Error
Could not open input file: composer.phar
Your command is trying to use composer which is not installed. It is not used to install composer. You have to install it using one of methods stated here:
https://getcomposer.org/doc/00-intro.md
The other option is that your path to composer file is wrong, which can also be fixed by following documentation.

"An error occured when executing the cache:clear --no-warmup" while installing symfony-cmf-standard

I was trying to install symfony-cmf-standard using:
composer.phar create-project symfony-cmf/standard-edition symfony-cmf-standard/ --stability=dev
But I am getting the following error:
Could not open input file: app/console
Script sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception
[RuntimeException]
An error occured when executing the cache:clear --no-warmup
I am running the command as an Administrator so it should not be a permission issue.
It gives error as when we use the command,
composer.phar create-project symfony-cmf/standard-edition symfony-cmf-standard/ --stability=dev
It creates symfony-cmf-standard folder as a project folder and starts installing dependencies but in between it tries to clear cache using
php app/console cache:clear
But as the current location is outside of the project folder it can not locate app/console so it fails.
Now if we change the directory to inside the project folder and clear cache manually by using command
php app/console cache:clear
It clears cache and then we need to again update dependencies using
php composer.phar update
It worked for me.
I've got an error cut also in the same case: "...PHP Fatal error: Class 'DOMDocument' not found..."
Works after:
install php-xml (can be optionally compiled with this option I suppose)
set date.timezone in /etc/php.ini
On my side with php7.0 I had to install :
php7.0-mbstring
php7.0-xml
Then it worked :)
This happens because of the following bug in DoctrinePHPCRBundle: https://github.com/doctrine/DoctrinePHPCRBundle/issues/17
To fix it, edit the file vendor/doctrine/phpcr-bundle/Doctrine/Bundle/PHPCRBundle/Resources/config/odm.xml inside your symfony-cmf-standard folder and replace this line:
<parameter key="doctrine_phpcr.odm.metadata.driver_chain.class">Doctrine\ODM\PHPCR\Mapping\Driver\DriverChain</parameter>
With this one:
<parameter key="doctrine_phpcr.odm.metadata.driver_chain.class">Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain</parameter>
Now copy composer.phar inside your symfony-cmf-standard folder and run with administrator privileges the command:
php composer.phar update
Make sure these are installed:
php-mb or php54w-mbstring or php55w-mbstring
php-xml or php54-xml or php55w-xml
After spending a couple hours on the issue, under FreeBSD you need to install port textproc/php80-xmlreader as well.

Categories