Laravel 5.2 Heroku Deployment Failed to install system packages - php

I am trying to deploy Laravel 5.2 project to heroku but I am getting the following error
-----> PHP app detected
-----> Bootstrapping...
-----> Installing platform packages...
! ERROR: Failed to install system packages.
Your platform requirements (for runtimes and extensions) could
not be resolved to an installable set of dependencies, or a
repository was unreachable.
Full error information from installation attempt:
> Loading repositories with available runtimes and extensions
>
> Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
> Nothing to install or update
> Generating autoload files
Please verify that all requirements for runtime versions in
'composer.lock' are compatible with the list below, and ensure
all required extensions are available for the desired runtimes.
For reference, the following runtimes are currently available:
PHP: 7.1.10, 7.1.9, 7.1.8, 7.1.3, 7.1.2, 7.1.1, 7.0.24,
7.0.23, 7.0.22, 7.0.17, 7.0.16, 7.0.15, 5.6.31, 5.6.30,
5.5.38
HHVM: 3.5.1
For a list of supported runtimes & extensions on Heroku, please
refer to: https://devcenter.heroku.com/articles/php-support
! Push rejected, failed to compile PHP app.
! Push failed
This is my composer.json file
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"barryvdh/laravel-ide-helper": "^2.1",
"components/jquery": "2.1.4",
"components/jqueryui": "1.11.4",
"kodeine/laravel-acl": "^0.1.3",
"laravelcollective/html": "5.2.*"
},
"require-dev": {
"symfony/dom-crawler": "~3.0",
"symfony/css-selector": "~3.0",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
],
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}
I ran have tried to deploy about a couple of dozens time after using composer install, composer update, composer update --lock and I even deleted the composer.lock file and ran composer update again but this error is not going anywhere. Please help!

It turned out that my vendor folder was not listed in .gitignore files and it was being pushed along with the other files on heroku. Once I added the vendor folder to .gitignore everything started working seamlessly.

Related

Laravel 5.3 project install : Script php artisan optimize handling the post-update-cmd event returned with error code 255

I am completely new in Laravel Framework and I am trying to install a Laravel project after cloning a project from Github. I followed all the steps mentioned in this post, but couldn't install the project.
It gets stuck every time on the "composer install" step. I get the following error which is same as when I do "composer update":
$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 4 installs, 8 updates, 0 removals
- Updating symfony/polyfill-mbstring (v1.3.0 => v1.4.0): Loading from cache
- Updating monolog/monolog (1.22.1 => 1.23.0): Loading from cache
- Updating nikic/php-parser (v3.0.5 => v3.0.6): Loading from cache
- Updating psy/psysh (v0.8.6 => v0.8.9): Loading from cache
- Updating symfony/polyfill-util (v1.3.0 => v1.4.0): Loading from cache
- Updating symfony/polyfill-php56 (v1.3.0 => v1.4.0): Loading from cache
- Updating symfony/event-dispatcher (v3.3.0 => v3.3.4): Loading from cache
- Updating guzzlehttp/guzzle (6.2.3 => 6.3.0): Loading from cache
- Installing composer/ca-bundle (1.0.7): Loading from cache
- Installing bugsnag/bugsnag (v3.5.1): Loading from cache
- Installing bugsnag/bugsnag-psr-logger (v1.1.0): Loading from cache
- Installing bugsnag/bugsnag-laravel (v2.6.0): Loading from cache
Writing lock file
Generating autoload files
Illuminate\Foundation\ComposerScripts::postUpdate
php artisan optimize
Script php artisan optimize handling the post-update-cmd event returned with error code 255
I have no idea what It does but following some suggestions on other posts, I also tried "composer update" and "composer update" followed by "composer dumpautoload". I have no idea what is wrong with it but nothing seems to work at all. I've searched for hours everywhere but couldn't find any solution. Anyone, please help.
Here is my composer.json file:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.6.4",
"laravel/framework": "5.3.*",
"intervention/image": "2.3.11",
"froala/wysiwyg-editor-php-sdk" : "*",
"chencha/share" : "^5.2",
"laravel/socialite": "^2.0",
"bugsnag/bugsnag-laravel": "^2.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"symfony/css-selector": "3.1.*",
"symfony/dom-crawler": "3.1.*"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist"
}
}
remove services.json file from bootstrap/cache folder and then run
composer dump-autoload -o

Composer error: UnexpectedValueException

My composer suddenly stopped working. I didn't even add new packages, just wanted to check, if there are any updates:
PS C:\data\www\project.dev> composer self-update
You are already using composer version 1.3.2 (stable channel).
PS C:\data\www\project.dev> composer update
> php artisan clear-compiled
The compiled class file has been removed.
Loading composer repositories with package information
Updating dependencies (including require-dev)
[UnexpectedValueException]
Could not parse version constraint >=~2: Invalid version string "~2"
update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock]...
All solutions I found so far suggested to update composer and check the composer.json, but there shouldn't nu anything wrong in there:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.3.*",
"edofre/laravel-fullcalendar-scheduler": "^1.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "5.0",
"symfony/css-selector": "2.8.*|3.0.*",
"symfony/dom-crawler": "2.8.*|3.0.*"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist"
}
}
As you can see, there is nothing special in there.
PS: Of course, I already chkecked this and this, but those are unrelated problems.
EDIT:
The Problem is fixed in the 1.3.0#dev version of the composer-asset-plugin.
It can be installed via:
composer global require fxp/composer-asset-plugin:~1.3#dev
See also: https://github.com/fxpio/composer-asset-plugin/issues/270
I have tracked down your problem using the verbose output of composer.
The problem is initially caused by requiring
"edofre/laravel-fullcalendar-scheduler": "^1.0"
Within this some bower packages are required ( For this I assume you installed Composer Asset Plugin -at least I had to do this as stated in the docs of laravel-fullcalendar-scheduler)
One of these bower packages is for example:
"bower-asset/fullcalendar-scheduler": "v1.4.0"
The Bower fullcalender-schedulare has some dependencies ( in bower.json):
"dependencies": {
"jquery": "2 - 3",
"moment": "^2.9.0",
"fullcalendar": "~3.2.0"
},
The used composer asset plugin translates the jquery dependency to:
">=~2,<4.0"
This finally causes the error in the composer module https://github.com/composer/semver which raises an error composer/semver/src/VersionParser.php:485
For testing i have manually changed the version to >=2.0 which is working.
I currently have not investigated wheter this is a bug in the composer/semver lib or a bug in the composer asset plugin.
The composer docs say that ~2 is a valid version number, but I don't know if it is supposed to be used in comparisons like ">~2" ( in my oppionion this makes no sense at all... )

Laravel - can't install from my source control

I need to automate my laravel project setup/upgrade on my production machine from source control.
I wrote a bash script to clone the source from the GIT repo and run the setup.
The git code is going to the folder /var/www/prod/mainapp/, so the following bash code is running after the git command:
cd /var/www/prod/mainapp/app/
composer install # composer update will not work as well
php artisan dump-autoload
php artisan optimize
I am getting the following error when the code reaches to: php artisan optimize
PHP Fatal error: Class 'App\Providers\SocialUserProvider' not found in /var/www/prod/mainapp/app/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 146
in my app.php i have the following providers:
App\Providers\FacebookGraphProvider::class,
Torann\GeoIP\GeoIPServiceProvider::class,
App\Providers\SocialUserProvider::class,
this is my composer.json:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"torann/geoip": "0.2.3"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"symfony/css-selector": "2.8.*|3.0.*",
"symfony/dom-crawler": "2.8.*|3.0.*"
},
"autoload": {
"classmap": [
"database",
"app/Facades",
"app/Services"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist"
}
}
You need to add to the classmap the line that will tell who should be autoloaded. app/Providers
"classmap": [
"database",
"app/Facades",
"app/Services",
"app/Providers" //this is the missing part.
]
I've come across this a few times.
My workaround is to run
composer install --no-scripts
You are getting that error due to the pre install scripts in your composer.json file and by adding that flag to the install process you skip these scripts.
Once you have everything installed you can then just use composer install and composer update as you usually would.

setting up server on bluehost for laravel application and having issue with php -v

I am setting up a fresh server for laravel application. I have installed composer and chosen php5.6.15 from my cpanel. But when I run php -v command in terminal it shows my current version as php5.2.19.
Here is my php.ini file on my server it show 5.6 version
I have uploaded my code to server using git. When I run command composer install it gives me this error.
Your requirements could not be resolved to an installable set of packages.
Problem 1
- laravel/framework v5.1.28 requires php >=5.5.9 -> your PHP version (5.4.43) or value of "config.platform.php" in composer.json does not satisfy that requirement.
- laravel/framework v5.1.28 requires php >=5.5.9 -> your PHP version (5.4.43) or value of "config.platform.php" in composer.json does not satisfy that requirement.
- Installation request for laravel/framework v5.1.28 -> satisfiable by laravel/framework[v5.1.28].
I am using laravel 5.1. If I downgrade it to 5.0 it gives dependency errors with other packages. Here is my composer.json file.
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.4.43",
"laravel/framework": "5.1.*",
"bestmomo/scafold": "dev-master",
"illuminate/html": "5.*",
"barryvdh/laravel-debugbar": "^2.0",
"intervention/image": "^2.3",
"doctrine/dbal": "^2.5",
"davejamesmiller/laravel-breadcrumbs": "^3.0",
"yajra/laravel-datatables-oracle": "^5.11",
"zizaco/entrust": "dev-laravel-5"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
],
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist",
}
}
I have php56 available under /usr/php/php56 and I can run it by making alias to it or just typing complete path. I also made an alias to it and after that php -v shows me 5.6.15 but when I run
composer install it still gives the same above output.
I may be unable to set default version of php cli to 5.6 or it is something with laravel framework support on bluehost servers. I think bluehost support is less concerned because I have composer which can do rest piece of work. Your help to sort out this issue is very much appreciated.
You should execute it like the following:
/usr/php/php56 composer.phar
I have to do something similar at HostGator for composer to work.
To grab composer.phar just run php -r "readfile('https://getcomposer.org/installer');" | php.

Deployment on Laravel Forge throwing faker not found Exception

I am trying to deploy a laravel project on forge and i am getting the below exception :
Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Faker\Factory' not found
I have the faker reference in require-dev in composer.json!
composer.json file
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*",
"tymon/jwt-auth": "0.5.*",
"dingo/api": "1.0.x#dev"
},
"require-dev": {
"fzaninotto/faker": "~1.5",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1",
"laracasts/testdummy": "1.*",
"laracasts/generators": "^1.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
],
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}
Deployment script in Forge:
git pull origin master
composer install --no-interaction --no-dev --prefer-dist
php artisan migrate --force
php artisan db:seed --class="StaticDataSeeder"
I was able to deploy the same project locally with out any problem and composer update on forge also runs successfully and i can see the faker package getting downloaded.
Please let me know if i am missing something.
There is a clear conflict that explains your problem:
You've added the "fzaninotto/faker" package to the require-dev section.
You're running the deployment composer install command with the --no-dev option which explicitly prohibits installing the packages listed in require-dev.
So the solution is either to move the package to the require section or remove the --no-dev option when deploying.
I have same problem on heroku deployment i think it same, i fix with
moving "fzaninotto/faker": "~1.4" from "require-dev" to "require" in composer.json and composer.lock
composer install
composer update
git add
git commit
git push heroku
if you don't use heroku as deployment don't run from step 4-6
Run the next command:
composer install
And the problem should go away

Categories