Retracing steps after composer update introduced log error - laravel

I'm working on my first laravel project, using laravel 5.1.28, homestead, and postgres.
Recently I updated composer.json for the first time in a while (and did composer update for the first time in a while), and now everything looks good in my sandbox, but my builds fail in heroku with the following error:
Generating optimized autoload files
php artisan clear-compiled
PHP Fatal error: Uncaught ReflectionException: Class log does not exist in /tmp/build_4b890192877bdbf1f605fbefdc7b2f34/dianekaplan-Family-laravel-e49374e/vendor/laravel/framework/src/Illuminate/Container/Container.php:741
I've read through about 5 threads for this error and tried the various fixes that resolved the different issues others had to lead to this error, but none of them seem to be mine.
So a different question: how do I go back in time from the perspective of composer? Does the composer.lock ride along with git so I could theoretically go back to that point, be able to have successful builds again, and then do a composer update again one day when I have a buddy and time to work through the fallout? (I'm a newbie, so an issue like this is crippling)
What approach can get me back to where I was for the time being?
Based on feedback in the comments I tried:
- replacing my composer.lock with a version that was in place back when builds were still succeeding (thank you, git!), then doing composer install (rather than update, so it would honor those old version numbers)- but afterward the build still failed with that same error above
- composer dump, composer update --no-scripts, and composer update (in that order), but afterward the build still failed with that same error above
:(:(:(
Here's what's in 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.1.*",
"doctrine/dbal": "^2.5",
"illuminate/html": "^5.0",
"laracasts/flash": "^1.3",
"cloudinary/cloudinary_php": "dev-master",
"jrm2k6/cloudder": "0.2.*",
"Illuminate/Support": "^5.1"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1",
"laracasts/generators": "^1.1"
},
"autoload": {
"classmap": [
"database",
"app/mailers"
],
"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've tried composer update on a 5.1 app using your composer.json, and didn't run into any issues - so the error likely comes from code somewhere in your app - it looks likely that you're using the Log facade to log something, eg. Log::error('message'), but you've written it as log::error('message'). After finding that, you may still have the same error when updating, in which case temporarily remove the following from composer.json before running composer update:
"pre-update-cmd": [
"php artisan clear-compiled"
],
On a side note there are a couple of other issues in your dependencies:
illuminate/html is deprecated/abandoned, replace it with laravelcollective/html instead.
illuminate/support is a part of laravel/framework, so is unnecessary and can be removed.

Related

How can update laravel 5.5 to laravel 8 without changing blade,route and auth

I have old 5.5 version laravel project file
when I run it , its ui not work
I think that need update . right?
I dont like laravel 8 blade template vue
How can I update to laravel 8 without losing functionality in project
here is composer file
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=7.0.0",
"coingate/coingate-php": "^2.0",
"fideloper/proxy": "~3.3",
"hesto/multi-auth": "^2.0",
"intervention/image": "^2.4",
"laravel/framework": "5.5.*",
"laravel/tinker": "~1.0",
"nwidart/laravel-modules": "^2.7",
"stripe/stripe-php": "^6.0"
},
"require-dev": {
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "~1.0",
"phpunit/phpunit": "~6.0",
"symfony/thanks": "^1.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/",
"Modules\\": "Modules/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
},
"files" :["app/Http/helpers/helpers.php"]
},
"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
}
}
laravel new version are more complex not simple as before
I like laravel but not like frequent updating new version
their UI depend on vue.js intentionally
According to my experience I upgraded from laravel 7.2 to laravel 8
Check upgrade
You have to check all dependencies required in version 8. As I remembered in version 5 routes are in app folder but in new version routes sre in root folder so you will face many problem.
There is more different b/w laravel8 into laravel5. Even folder structure are different so.
If you developed your projects then develop from scratch.
Download a fresh laravel without any package
check dependencies and all packages mentioned in your old projects composer.json and composer.lock . Don't forget to check package.json if exists
Now mention all the packages (with upgraded version by comparing using link ) in your new projects composer.json file .
composer update
Now you have to check if your projects can run in upgraded version.
5. Copy vendor folder composer.json file and composer.lock and bootstrap folder
6. Now php artisan serve
7. If your projects running smoothly then go further
8. Copy your routes.php from app folder of old project to routes/web.php new projects
9. Copy all view from old projects to new projects
10. Copy all your models and all your controllers
11. Now add "files" :["app/Http/helpers/helpers.php"] lines in composer.json
12.now composer dump-autoload
Then run your server if runs well then your code can work on version 8 environment.
don't forgot to check all folder from app and config folder if you find any extra file just copt it p.
Now here is an problem with your admin panel or login panel if you have otp or another extra feature do it from scratch.
here is no commands to upgrade from version 5 to version 8.
I have had tried to upgrade a project from 5.6 to 8, and outcome in summary: don't bother.
Syntaxes are different (e.g., routes). Folder structure is same, and about this
'UI depend on vue.js intentionally', you can just not use those files and make new. Yes by default they are now using tailwind, but just delete the file and make your own UI, in any framework you want. Or just use blades.
As the other comment also mentioned, you're better off creating a new Laravel 8 project and then importing modules 1-by-1 and change codes if necessary. In all fairness you'll be doing the same work if you try to upgrade from 5.6 to 8 but with more hassle.

Composer update not installing the entirety of Laravel app

On deploying my application through Laravel Forge, I'm presented with the following errors:
Fatal error: Class 'Illuminate\Support\Arr' not found in
/home/forge/toono.co/vendor/laravel/framework/src/Illuminate/Support/helpers.php
on line 151
This is after the composer update command has ran. I have SSH'd into the directory and low and behold, the file Arr.php doesn't exist.
The code is pulled from the master branch in BitBucket, and then the following lines are executed on the production server:
cd /home/forge/default
git pull origin master
composer install
php artisan migrate --force
Composer.json:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"laravel/framework": "4.2.*"
},
"require-dev": {
"way/generators": "2.*",
"fzaninotto/faker": "1.4.*#dev",
"barryvdh/laravel-debugbar": "1.*",
"flynsarmy/csv-seeder": "1.0.*"
},
"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 debugbar:publish",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "stable"
}
Composer.lock:
"require": {
"codesleeve/stapler": "~1",
"laravel/framework": "~4",
"php": ">=5.4.0"
}
Why has composer update missed that file? After a local update and even on the master branch in Github, Arr.php is there?
If I am missing any necessary code that you require, please let me know.
Any help would be greatly appreciated.
I solved this by deleting composer.lock and the vendor folder within the production server. I then used composer update.
I solved this by ssh'ing into the box via commandline (ssh forge#ip.of.server)
if you don't know how to ssh into the server, you go to forge -> the server -> SSH Keys.
There you add your public key (if you have not setup ssh keys follow this guide: https://help.github.com/articles/generating-ssh-keys).
If you have ssh keys setup, you simply open terminal and paste the following command and run it; "pbcopy < ~/.ssh/id_rsa.pub", this will copy your public key to your clipboard and you can simply paste that into the ssh key field in forge.
Now i can ssh into the server.
I then navigated to the default folder (cd /home/forge/default) and ran "composer update"
It updates everything and it worked after that.

Composer not downloading src directory for packages

I'm using Laravel and Composer to build a web app.
On my local machine I have its requirements setup within the composer.json file and everything works as it should.
I'm using Github to push to the production server, however, I then run composer install and add the providers and aliases for one of my packages, I then get an error saying that the service provider hasn't been found.
I then proceeded to check the vendor folder, which had the directory in it for the package, but within this directory it's missing all the files/folders, such as the composer.json, src directory, etc.
Any ideas why these are not being downloaded? The src directory for other packages are fine, like symfony, laravel, but not the packages I've set as required.
The package I'm using is artdarek/oauth-4-laravel, on my local machine it downloaded fine including the src directory, etc.
Oh and I'm using Forge by Laravel to deploy to a cloud server at Digital Ocean.
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "4.2.*",
"artdarek/oauth-4-laravel": "dev-master"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
],
"psr-4": {
"Karl\\": "app/Karl"
}
},
"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"
}
This might work. Try updating composer (to keep current) and updating your app:
composer self-update
composer install
composer update
I had a slightly similar issue that install didn't resolve but update did

Problems installing dependencies by Composer

When I generate the command "php composer.phar install" I get the following error:
{"error":{"type":"PDOException","message":"SQLSTATE[42000] [1044] Access denied for user ''#'localhost' to database 'database'","file":"/var/www/wingtech/wingadmin/public_html/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php","line":47}}Script php artisan optimize handling the post-install-cmd event returned with an error
http://oi42.tinypic.com/20uc2ma.jpg
Curiously, when I set up a database in app/config/database.php before running the install of the composer this error does not appear
To ease my php version is 5.4.17
And my composer.json is:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "4.0.*",
"orchestra/asset": "2.0.*"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/library",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "dev"
}
Does anyone know what could be?
You can run Composer without it running Laravel scripts using the following switch:
php composer.phar install --no-scripts
Similar behavior (artisan optimize returning an error) happened when running on php < 5.3 or with multiple php versions and needing to specify the php version in the command line, ie php542 composer.phar install - similar issue here.
But the PDO exception is weird, could you check the scripts part of composer.json ? Is there anything more than the default stuff there?
Do you have an .env file? This is a typical error of the artisan script when the .env file is missing.

How do I set up Bootstrap after downloading via Composer?

I'm a beginner with Composer, so I know little about it and have little experience with web application development.
I was reading the Nettuts+ Tutorial, and have a basic question about Composer.
{
"require": {
"laravel/framework": "4.0.*",
"way/generators": "dev-master",
"twitter/bootstrap": "dev-master",
"conarwelsh/mustache-l4": "dev-master"
},
"require-dev": {
"phpunit/phpunit": "3.7.*",
"mockery/mockery": "0.7.*"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
"scripts": {
"post-update-cmd": "php artisan optimize"
},
"minimum-stability": "dev"
}
If I set up my composer.json file as above, after executing composer install --dev, how do I make Bootstrap available for use in the Laravel project?
I mean, I can see the Bootstrap package is downloaded to the vendor directory. Before I only used to download Bootstrap from its official website and manually put the files in the public directory of Laravel, but what is the right way to do this here? Can I leave the Bootstrap files where they are, because I want to update the Bootstrap package to its latest version periodically?
Thanks.
We have artisan command to publish the assets(CSS, JS,..). Something like this should work.
php artisan asset:publish --path="vendor/twitter/bootstrap/bootstrap/css" bootstrap/css
php artisan asset:publish --path="vendor/twitter/bootstrap/bootstrap/js" bootstrap/js
i am not sure about the path.. But this should work.
As the tutorial says, you have to copy it to your public directory:
cp vendor/twitter/bootstrap/docs/assets/js/html5shiv.js public/js/html5shiv.js
cp vendor/twitter/bootstrap/docs/assets/js/bootstrap.min.js public/js/bootstrap.min.js
EDIT:
You really have copy them, because your assets files should lie in the public folder only and Composer is all about putting packages on your vendor's folder, which must not be visible to the outside world.
But you can create a Composer post-install-cmd:
{
"scripts": {
"post-update-cmd": "MyVendor\\MyClass::postUpdate",
}
}
And make it copy those files for you every time an update happens. It can be written using PHP, bash or any other language you can run on your host. Docs: http://getcomposer.org/doc/articles/scripts.md.
Just realised that php artisan asset:publish --path="vendor/twbs/bootstrap/dist/" bootstrapor php artisan vendor:publish --path="vendor/twbs/bootstrap/dist/" bootstrap do not work anymore.
What worked for me is editing the composer.json to add the following under scripts, post-update-cmd:
"scripts": {
"post-update-cmd": [
"php artisan optimize",
"mkdir -p public/bootstrap",
"cp -R vendor/twbs/bootstrap/dist/ public/bootstrap/"
]}
Just symlink the folder like said above by LeviXC:
{
"scripts": {
"post-update-cmd": "ln -sf vendor/twitter/bootstrap/dist/ public/vendor/bootstrap/"
}
}
Or multiple commands:
{
"scripts": {
"post-update-cmd": [
"php artisan optimize",
"ln -sf vendor/twitter/bootstrap/dist/ public/vendor/bootstrap/"
]
},
}
The solution with composer post update script (post-update-cmd) in Windows environment could be:
{
"require": {
"twbs/bootstrap": "4.3.1"
},
"scripts": {
"post-update-cmd": [
"RMDIR public\\assets\\bootstrap /S /Q" ,
"XCOPY /E /I vendor\\twbs\\bootstrap\\dist public\\assets\\bootstrap"
]
}
}
You will have the bootstrap files inside public\assets\bootstrap folder ready to be imported in HTML.
This worked better for me
"scripts": {
"post-update-cmd": [
"mkdir -p html/vendor/",
"ln -sfr vendor/twbs/bootstrap/dist html/vendor/bootstrap"
]
},
The "r" flag made the symlink relative, thus pointing to the real folder
I am new to Laravel and Bootstrap (and to using them together) and I stumbled across this thread when having the same issue. I created a new Laravel project, then added Bootstrap by running the following command from within the root directory of the Laravel project:
%composer require twbs/bootstrap
Then, in my view file, I included the following code:
<link href="css/app.css" rel="stylesheet">
It appears that composer (or bootstrap) adds app.css which includes the Bootstrap css files (which are located in the non-public vendor folder) by reference. Adding the reference to app.css worked, and I was able to use Bootstrap components in my view.

Resources