I manage a several year old app for which I am not the original developer.
The site has been running on AWS EB since late 2014 - using laravel 4.
Today, AWS terminated my ec2 instance as the type of box is being retired. The new instance spawned without issue, but the app was not running.
When I try to deploy an version of theapp (via zip), I get the following error:
[Instance: i-03441954f29775f02] Command failed on instance. Return
code: 1 Output:
[CMD-AppDeploy/AppDeployStage0/AppDeployPreHook/10_composer_install.sh]
command failed with error code 1:
/opt/elasticbeanstalk/hooks/appdeploy/pre/10_composer_install.sh ++
/opt/elasticbeanstalk/bin/get-config container -k app_staging_dir +
EB_APP_STAGING_DIR=/var/app/ondeck + cd /var/app/ondeck + '[' -f
composer.json ']' + export COMPOSER_HOME=/root + COMPOSER_HOME=/root +
'[' -d vendor ']' ++ /opt/elasticbeanstalk/bin/get-config
optionsettings -n aws:elasticbeanstalk:container:php:phpini -o
composer_options + PHP_COMPOSER_OPTIONS= + echo 'Found composer.json
file. Attempting to install vendors.' Found composer.json file.
Attempting to install vendors. + composer.phar install --no-ansi
--no-interaction [UnexpectedValueException] .
I, unfortunately, have not been much of a PHP developer for the past 4-5 years, so I am a little confused as to where to start. It seems like an issue with the file itself, this is what I have:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "4.2.*",
"zizaco/confide": "~4.0#dev",
"dollar/generators": "dev-master",
"anahkiasen/former": "dev-master",
"guzzlehttp/guzzle": "~4.0",
"rhumsaa/uuid": "~2.7",
"aws/aws-sdk-php-laravel": "1.*",
"nesbot/Carbon": "*",
"maatwebsite/excel": "1.*",
"mandrill/mandrill": "1.0.*",
"barryvdh/laravel-snappy": "0.1.x",
"h4cc/wkhtmltopdf-amd64": "0.12.0",
"davibennun/laravel-raygun": "dev-master",
"dchesterton/marketo-rest-api": "^0.0.5"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"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"
}
Beyond this, I ma not sure if there's something i need to do to the EC2 box itself. I will say that the server has been regenerated in the past - probably not for 2 years or so, without issue.
These are the server specs from EB.
64bit Amazon Linux 2014.09 v1.0.9 running PHP 5.5
this issue happened to me as well, after digging deep into the /var/log/eb-activity.log (you have to ssh into your instance to access this log file) i found out that some packages in my composer.json were requiring PHP version 7.3 and in my Instance, I had PHP 7.2.
What I did to resolve this was to downgrade the dependences (laravel-websockets in my case) from 1.3 to 1.2 because currently PHP 7.3 is not supported by the elastic beanstalk.
But you can also upgrade your PHP version if this is the case.
In order to really know what is the problem, it is better to visit the log file /var/log/eb-activity.log
Related
My project is a Laravel implementation. I have created a composer.json file as follows:
{
"name": "company/project",
"description": "My cool project.",
"type": "project",
"license": "proprietary",
"require": {
"laravel/laravel": "8.*"
}
}
I can put this file in its own directory and run composer install. This installs version 8 of laravel/laravel and all dependencies in the vendor/ directory. But this is not a valid Laravel installation. If I then move the contents of vendor/laravel/laravel up into the main directory, copy .env.example to .env and run composer -o dump-autoload, then I have a directory structure that looks (as far as I can tell), just like a standard Laravel installation.
However, when I try to access the site from by browser, I get a 500 Server Error, with no apparent entries in the Apache or Laravel logs.
I know this is not an Apache configuration error because I can create exactly the same site using the command composer create-project laravel/laravel:8.* {directory}, and I get a function basic Laravel site.
My ultimate goal is to use composer to install my project AND Laravel, with all of it's dependencies, and get a functioning site. I am particularly interested in being able to lock all of the dependencies (including the specific version of laravel/laravel) via the composer.lock file, which will then be included with the version-controlled source of my project.
You may ask why I don't just use the recommended command to create a clean Laravel installation and just version-control the resultant composer.lock file. The reason is: That file does not contain the specific version of laravel/laravel. So when I then user the composer.json/lock files in a clean directory, the core laravel/larvel files are missing.
Any pointers as to what I am doing wrong? Or is there a simpler way to achieve my goal?
Your composer.json only requires "laravel/laravel": "8.*", but Laravel needs a lot more to function properly. When I do a composer create-project laravel/laravel it generates a composer.json with the following:
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"php": "^7.3|^8.0",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"laravel/framework": "^8.54",
"laravel/sanctum": "^2.11",
"laravel/tinker": "^2.5"
},
"require-dev": {
"facade/ignition": "^2.5",
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.2",
"nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^9.3.3"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover --ansi"
],
"post-update-cmd": [
"#php artisan vendor:publish --tag=laravel-assets --ansi"
],
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate --ansi"
]
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
Now this does a lot more than just requiring a vendor-folder, these contain the namespace-declarations, scripts, and the requirements for a few more things.
And also note that this requires laravel/framework instead of laravel/laravel.
All in all I suggest using the full list from here and keep stripping until it breaks if you want to.
And on the subject of version pinning, you could either put the composer.lock-file in your VCS and only run composer install (that does not update if there is lock-file).
You could also remove the ^ from all the versions that you don't want to update, that way you can restrict a version with some room for updates if you want. 8.0.1 would keep at 8.0.1, but you could allow patches by specifying 8.0.* as a version-requirement.
In the end, I gave up trying to make this work. Instead, I now follow these steps to install a new site:
composer create-project --no-install --no-scripts laravel/laravel:{version} {SITE}
cd {SITE}
svn export --force {repo}/composer.json .
svn export --force {repo}/composer.lock .
composer install
svn co {repo} .
svn -R revert .
This allows me to create a site with the specific version of Laravel that I need.
after upgrading Laravel according to the docs to v7 I ran composer update. Then I'm getting this:
Script #php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255
This is my composer.json file:
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.1.3",
"fideloper/proxy": "^4.0",
"guzzlehttp/guzzle": "^6.5",
"kitetail/zttp": "^0.6.0",
"laravel/framework": "^7.0",
"laravel/tinker": "^2.0",
"laravel/telescope": "^2.1",
"laravelcollective/html": "^6.0",
"livewire/livewire": "^0.7.4",
"spatie/laravel-html": "^2.24",
"spatie/laravel-permission": "^3.0.0"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.2",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"laravel/ui": "^2.0",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^4.1",
"phpunit/phpunit": "^7.5"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover --ansi"
],
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate --ansi"
]
}
}
I'm confused right now. It even seems that php artisan doesn't do anything in this project. In other projects it's just working fine. Any idea how this could be fixed?
Edit: Some of the answers provided suggestions. I'm getting the following using Laragon:
PS C:\laragon\www\attila> composer update
Updating dependencies (including require-dev)
Package operations: 0 installs, 4 updates, 0 removals
- Updating laravel/framework (v7.0.1 => v7.0.2): Downloading (100%)
- Updating spatie/laravel-permission (3.10.1 => 3.11.0): Downloading (100%)
- Updating laravel/ui (v2.0.0 => v2.0.1): Downloading (100%)
- Updating nunomaduro/collision (v4.1.1 => v4.1.2): Downloading (100%)
Package moontoast/math is abandoned, you should avoid using it. Use brick/math instead.
Writing lock file
Generating optimized autoload files
> #php artisan package:discover --ansi
Script #php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255
PS C:\laragon\www\attila> php artisan package:discover --ansi
PS C:\laragon\www\attila>
After deleting all the cache in bootstrap & storage/framework folders, still no results.
Running the php artisan --help returns some errors, this gave me a hint where the problem is.
After checking the Upgrade Guide I solved the issue, for me it was:
Changes in App\Exceptions\Handler methods
install require laravel/ui package
For me, it was a very simple error and fix.
The relevant portion of the 7.x Upgrade docs says the following:
Symfony 5 Related Upgrades Likelihood Of Impact: High
Laravel 7 utilizes the 5.x series of the Symfony components. Some
minor changes to your application are required to accommodate this
upgrade.
First, the report, render, shouldReport, and renderForConsole methods
of your application's App\Exceptions\Handler class should accept
instances of the Throwable interface instead of Exception instances:
use Throwable;
public function report(Throwable $exception);
public function shouldReport(Throwable $exception);
public function render($request, Throwable $exception);
public function renderForConsole($output, Throwable $exception);
Relevant file: ./App/Exceptions/Handler.php
Change: convert instances of "Exception" to "Throwable" (editor search and replace)
So, basically, once I put the change in place, 'php artisan' started to work again.
This included the package:discover command in the OP's composer.json (and mine).
I tried putting it back to Exception, and the artisan command would fail to do anything.
Change the occurrences of Exception to Throwable, and everything works. (My application only had the first two functions defined, though.)
So, it pays to pay attention to the documentation.
You must delete old files (cache). This commands should works:
cd bootstrap/cache/
rm -rf *.php
composer update
If you are work on regular user, add sudo before each command.
Try this :
cd bootstrap/cache/
rm -rf *.php
Then composer update again.
After following the upgrade guide in the docs some folks in the Laravel Discord chat guided me to update the Symfony 5 Related Upgrades.
I had to remove telescope (which I'm not using) too.
If you are using Laravel 7 for some reason while your install composer 3.x installed on your system. use following command:
composer require laravel/ui ^2.0
I went to update composer using
composer update
after update having the following error:
FatalErrorException in Inflector.php line 265: syntax error,
unexpected ':', expecting ';' or '{'
Please assist
Thanks in advance
Using Laravel Framework version 5.2.45
here is the composer code
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"laravelcollective/html": "*.*"
},
"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"
],
"psr-4": {
"App\\": "app/"
},
"files": [
"app/Libraries/Functions.php"
]
},
"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"
}
}
Please see the function of inflector.php where error occures
public static function tableize(string $word) : string
{
return strtolower(preg_replace('~(?<=\\w)([A-Z])~', '_$1', $word));
}
It's a PHP version issue, update to PHP 7.0 and doctrine/inflector will work properly because doctrine/inflector 1.20 and above require PHP 7.
But if you want to stay at your current PHP version, you can downgrade the doctrine/inflector version by running the following commands:
Delete the composer.lock file
rm -f Composer.lock
Delete the vendor
rm -R -f vendor
composer install
Install the doctrine/inflector according to your php version
composer require doctrine/inflector:1.1.0
doctrine/inflector:1.1.0 supports PHP 5.6 & above. If you have another version of php, you can refer to this link
It's really obvious when you search for this file name and then start comparing package versions.
You are requiring laravelcollective/html at any version, so, for now, the latest version is 5.5.x. This package in its turn requires "doctrine/inflector": "~1.1",, so any version below 2.0, which is currently 1.3.0 and requires PHP 7.0 or higher.
If you look at the source of the latest inflector.php, you will see a return type is set on line 265, which is only supported in PHP 7.0 and up.
You are using PHP 5.6.24, so this code won't work on your system.
The simple way to fix your error is to use the laravelcollective/html version corresponding to your Laravel version. Which should probably be 5.2.*.
I'm working on:
Laravel 5.1
PHP 5.6.36
My table name is like this: "test_meetings"
I solved the error specifying in testMeeting.php Model the table name:
protected $table = 'test_meetings';
In case this helps anyone. I had a similar problem. My doctrine/inflector was expecting php>=7 for some reason (That's what was to found in the composer.json from doctrine/inflector). And this even though I had followed the instructions to install laravel 5.4.
I ran rm -f Composer.lock and rm -R -f vendor and then did a composer install after vagrant ssh to the homestead VM, which was using php 5.6.8 (originally I had run composer from my MacBook terminal, which was using php 7)
This cleared up the issues.
Delete composer.lock file
`rm -f Composer.lock`
Delete the vendor folder
rm -R -f vendor
composer install
Then you can install a specific version of doctrine/inflector using composer
for example:
composer require doctrine/inflector:1.2.0 (this will work with php 7.0)
Also, it helps me to resolve the build issue to upgrade carbon if you are using
composer require nesbot/carbon=1.29.*
after
composer install
Try this after you have run the composer update:
php artisan cache:clear
I solved my problem by explicitly giving table name in model
protected $table = 'table_name';
For last 3 days, I am trying to install laravel 5.5 in my system(windows 8.1) through composer and getting a series of errors one after other. So I am asking some questions in order to clear my doubts which are still doubted after more than 20-25 hour of research on various blogs and SO.
I have installed php 7 in c:\php.
After that, I have installed composer using composer installer and did nothing after that, like setting PATH on environment setting.
I found that I have to create a composer.json file which I have copied from Github and shown below, but I don't know where to keep this composer.json file so I created this file on C:\Users\MyPC (i.e. my home directory).
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=7.0.0",
"fideloper/proxy": "~3.3",
"laravel/framework": "5.5.*",
"laravel/tinker": "~1.0"
},
"require-dev": {
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~6.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": [
]
}
},
"scripts": {
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
}
}
Please check the code above if I have committed any mistake.
After that I executed "composer update" command which downloaded a lot of files and placed in C:\Users\MyPC\vendor folder (I think), but throws an error at last which I can't remember.
After that I executed "composer install" command and get this error shown below.
This is my problem and I am not able to figure out what to do.
I have a couple of more doubt:
a - composer create-project --prefer-dist laravel/laravel NAME_OF_PROJECT can also be used to set up new project then why we use composer global require “laravel/installer” and then laravel new NAME_OF_PROJECT method. What are the benefits of using this method.
b - What are the steps to follow after the installation of the composer using the installer for setting up a new laravel project. What are the best practices to structure the project folder?
Please help me. I am learning laravel but don't know how to deal with this composer stuff and installing laravel as most or all of the tutorial starts with creating new project file .they don't teach how to install them.
Ok so a lot of research and try and errors I figured out a way that worked for me. I am using Windows 8.1.
I have installed php 7 in c:\php.
Note : Download php from
http://php.net/downloads.php. Download Non Thread Safe
version in zip format and extract it to the
desired folder (I extracted in C:\php).
After that I have installed composer using composer installer and did nothing after that, like setting PATH on environment setting, Installer will do it for you.
Download Composer Installer from https://getcomposer.org/download/.
After that I have downloaded laravel from github and exctrated to the desired project folder.
Download Laravel latest version from https://github.com/laravel/laravel
After that I ran "composer self-update"command.
After that I ran "composer update"command.
After that I ran "composer global require “laravel/installer”"command. This command will install Laravel Installer.
Now I can go to the project folder directory and run "laravel new myProjectName" command to create new laravel project.
I've created my laravel project with create-project beacause composer install didn't work.
cd to my project and then, when I try to use php artisan list or any artisan command it just says:
Could not open input file: artisan
How do I fix this? the vendor file is in the project
My composer.json:
{
"name": "vendor_name/package_name",
"description": "description_text",
"minimum-stability": "stable",
"license": "proprietary",
"authors": [
{
"name": "author's name",
"email": "email#example.com"
}
],
"require": {
"barryvdh/laravel-ide-helper": "^2.0"
}
}
path to my project:
c:\wamp\www\project1
Inside vendor, no folder named artisan is showed
Use the project's root folder
Artisan comes with Laravel by default, if your php command works fine, then the only thing you need to do is to navigate to the project's root folder. The root folder is the parent folder of the app folder. For example:
cd c:\Program Files\xampp\htdocs\your-project-name
Now the php artisan list command should work fine, because PHP runs the file called artisan in the project's folder.
Now install the laravel framework
Keep in mind that Artisan runs scripts stored in the vendor folder, so if you installed Laravel without Composer, like downloading and extracting the Laravel GitHub repo for laravel, then you don't have the framework itself and you may get the following error when you try to use Artisan:
Could not open input file: artisan
To solve this you have to install the framework itself by running composer install in your project's root folder.
Have you tried to do a "ls" (linux) or a "dir" (win) to make sure you are in the correct folder?
Check if you have correctly installed php.
Run cmd or shell and try to run
php -v
I'm going to assume you have Windows as your OS.
Go to Control Panel -> System and Security -> System -> Advanced system settings.
Then go to Environment Variables, find "Path" and add
;your/path/to/php.exe
at the end.
Replace "your/path/to/" with your current php.exe directory (including C:\ )
EDIT
Try with this one:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"laravel/framework": "5.0.*",
"barryvdh/laravel-ide-helper": "^2.0"
},
"require-dev": {
"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"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php -r \"copy('.env.example', '.env');\"",
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}
I'm using windows 10, today is 31st dec, 2016.
I had the same issue, did a bit of a research and solved it.
First go to vendor directory from your laravel project directory and run this command:
composer install
if it further shows an error and asks for the composer.json file missing then:
cd ../
composer install
This fixed my issue!
I don't know if this has been solved, but I found this to be useful:
composer require laravel/passport --ignore-platform-req=ext-fileinfo