I am a newbie into Heroku and I know many similar questions have been asked on stackoverflow for this but I could not find any solution that works for me.
I am getting the following issue when trying to deploy my laravel 4.2 app:
remote: > php artisan clear-compiled
remote: Mcrypt PHP extension required.
remote: Script php artisan clear-compiled handling the post-install-cmd event returned with error code 1
remote: ! Push rejected, failed to compile PHP app.
I tried to connect to heroku environment with heroku run bash
command but could not get the status of mcrypt extension as no root permissions are granted to me.
Also tried to set heroku buildpacks:set https://github.com/heroku/heroku-buildpack-php
as buildpack. But no success.
Here is my composer.json
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "4.2.*"
},
"autoload": {
"classmap": [
"app/commands",
"app/library",
"app/controllers",
"app/models",
"app/Lib.php",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "stable"
}
Any help is much appreciated.
You haven't specified a PHP version or a dependency on the mcrypt
extension in your composer.json
.
Start by depending on a particular version of PHP:
composer require php ~7.1.0
You can replace ~7.1.0
with ~7.0.0
or ~5.6.0
if you prefer.
Heroku includes mcrypt
by default if you are using PHP 5.6. But if you're using 7.0 or 7.1 you'll need to add it:
composer require ext-mcrypt
Then update your composer.lock
by running composer update
. Make sure everything is still working as expected locally, then commit the updated composer.json
and composer.lock
files and push to Heroku again.
Note that the mcrypt
extension has been deprecated as of PHP 7.1. It is probably worth considering an upgrade to Laravel 5.1 or higher which replaces mcrypt
with openssl
, especially if you're working with PHP 7.1.