Laravel 5.1 PHPUnit 503 error - laravel

Currently stumped on a test that is returning a 503 error for no reason. Running Laravel 5.1 and latest PHPUnit.
The test:
$this->call('GET', '/about');
$this->assertResponseStatus(200);
Fails because it returns a 503 error, other tests (similar GET calls) pass.
If I dd($this->call()) I can see the entire html response is returned but still has a 503 error attached. No errors in the logs either. The page loads fine in a browser, no 503 error.
edit:
Route::group(array('after' => 'cache:1440'), function() {
Route::get('about', 'HomeController#showAbout');
}
edit2:
dd($this->call('GET', '/about'));
yields full html+
version: "1.1"
statusCode: 503
statusText: "Service Unavailable"
charset: null
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.*",
"laravelcollective/html": "~5.0",
"intervention/image": "dev-master",
"watson/sitemap": "2.0.*",
"rap2hpoutre/laravel-log-viewer": "dev-master",
"barryvdh/laravel-httpcache": "0.2.x#dev",
"guzzlehttp/guzzle": "~5.3|~6.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database",
"app/Http/Controllers",
"app/Models",
"app/Helpers"
],
"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-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "dev",
"prefer-stable": true
}

Alright I found the issue for some reason flushing and clearing the cache did not work for the barryvdh\laravel-httpcache library, I had to manually delete everything under storage/httpcache

Related

Composer error deploying laravel application on elasticbeanstalk

I have a laravel app hosted on elastic beanstalk and it is also connected with code pipeline. When I deployed the application I got this error on ebs panel:
ERROR: During an aborted deployment, some instances may have deployed the new application version. To ensure all instances are running the same version, re-deploy the appropriate application version.
I don't know if it is related but when I downloaded the logs I found this:
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> #php artisan package:discover --ansi
Script #php artisan package:discover --ansi handling the post-autoload-dump event
returned with error code 1
Here is my composer.json
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.3|^8.0",
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.3",
"laravel/framework": "^8.12",
"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"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\": "app/",
"Database\Factories\": "database/factories/",
"Database\Seeders\": "database/seeders/"
}
},
"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"
]
}
}
It seems that you have some typos. The special character "\" must be "\\" for folder separation.
try this composer.json:
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.3|^8.0",
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.3",
"laravel/framework": "^8.12",
"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"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": []
}
},
"autoload": {
"psr-4": {
"App\\": "app /",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}
},
"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"
]
}
}
Now composer must be able to run scripts. Composer install must finish installation or give you clear warning or error about files.
So I just find out what was going on! I tried to increase my instance and then when I downloaded the complete log there were new information:
021/05/25 18:00:11.083949 [INFO] Running command /bin/sh -c composer.phar install --no-ansi --no-interaction
2021/05/25 18:00:18.791014 [INFO]
ParseError
syntax error, unexpected character 0x1D, expecting "]"
at app/Http/Controllers/MailController.php:28
24▕ 'nome' => $request->nome,
25▕ 'email' => $request->email,
26▕ 'assunto' => $request->assunto,
27▕ 'descricao' => $request->descricao,
➜ 28▕ 'local' => $request->localizacao,
29▕ 'pais' => $request->pais
30▕ ]);
31▕
32▕ if($response->status() === 200)
[2m+1 vendor frames [22m
2 [internal]:0
Composer\Autoload\ClassLoader::loadClass("App\Http\Controllers\MailController")
[2m+9 vendor frames [22m
12 routes/web.php:24
Illuminate\Support\Facades\Facade::__callStatic("post")
2021/05/25 18:00:18.791081 [ERROR] An error occurred during execution of command [app-deploy] - [Install composer dependencies]. Stop running the command. Error: installing composer dependencies failed with error: Command /bin/sh -c composer.phar install --no-ansi --no-interaction failed with error exit status 1. Stderr:Do not run Composer as root/super user! See https://getcomposer.org/root for details
I couldn't see those ascii on vscode but when I opened the project with sublime they were there! I guess my instance was running out of memory therefore It wasn't logging out much and when I changed tiers, more information was logged out. I just removed those ascii and now it is working just fine.

How update Laravel to 6?

I am trying to upgrade laravel to version 6 to php 7.4. How can I change the composer (its content is below) so that it pulls the plugins of compatible versions necessary for the project?
Compatibility errors occur when changing only laravel version
how do I understand which versions of plugins to write in composer so that it builds projects correctly? I have a lot of problems with him when changing versions ...
{
"name": "Codecast's Single Page Application Starter Kit",
"description": "This is the web service to support the kit.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=5.6.4",
"laravel/framework": "5.3.*",
"barryvdh/laravel-cors": "0.8.*",
"tymon/jwt-auth": "~1.0",
"predis/predis": "~1.1",
"league/fractal": "0.14.*",
"jenssegers/agent": "^2.6"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~5.0",
"symfony/css-selector": "3.1.*",
"symfony/dom-crawler": "3.1.*",
"squizlabs/php_codesniffer": "~2.3",
"scriptixru/sypexgeo": "0.2.*#dev"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/Support/",
"tests/TestCase.php",
"tests/ApiTestCase.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"
],
"test": "phpunit --colors=always",
"check-style": "phpcs -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 ./app ./config ./routes",
"fix-style": "phpcbf -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 ./app ./config ./routes"
},
"config": {
"preferred-install": "dist"
}
}

Laravel: Update from 5.2.12 to 5.2.31

I have a Laravel 5.2.12 project (website), it's a big project and it's almost finished... Is there any simple way to update the Laravel from 5.2.12 to 5.2.31 without affecting the project (without affecting what was already done)? How can I do this?
So, the question is how to update the version of Laravel on existing project from 5.2.12 to 5.2.31?
EDIT: Here 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.*",
"cartalyst/sentinel": "2.0.*",
"intervention/image": "^2.3",
"barryvdh/laravel-debugbar": "^2.2",
"slynova/laravel-commentable": "^2.0",
"barryvdh/laravel-ide-helper": "v2.2.2"
},
"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/"
}
},
"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"
}
}
What should be changed to update just Laravel to 5.2.31 (to the latest 5.2 version)?
Update composer.json to use laravel\laravel on the version you would like. Then run composer update in you command line.
Your project should not have any issues updating from 5.2.12 to 5.2.31 since they are mostly bugfixes. But do note that other dependencies might update to a new version. So you might want to set them to a fixed version in your composer.json file if the cause hickups.

Laravel 5 composer update not working?

I am using Laravel version 5.2 and Jenssegers MongoDB. I installed both and working fine but I have to use any other library and made changes in composer.json after that use command composer update. After using this command automatically Jenssegers MongoDB file removed. I don't know why this happen. After composer update why Jenssegers MongoDB file removed automatically? Please suggest me how to handel this?
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.*",
"acacha/admin-lte-template-laravel": "2.*"
},
"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/common_helper.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"
}
}
Write this "jenssegers/mongodb": "*", line in your composer.json file:-
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"acacha/admin-lte-template-laravel": "2.*",
"jenssegers/mongodb": "*",
},
And add the service provider in config/app.php
Jenssegers\Mongodb\MongodbServiceProvider::class,
Jenssegers\Mongodb\Auth\PasswordResetServiceProvider,
then go to project root directory in terminal and run command composer update .
In model file, you need to add below line at the top,
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
Reference :- documentation
composer update --no-scripts
you can stop scripts run

plivo api intallation via composer conflict with guzzle

I am installating plivo api using composer on live server(digital ocean), which running command i getting some dependencies version mismatch errors.
plivo required guzzle latest version, but guzzle is already installed in my laravel application but its version is old.What i need to do to resolve this error.
please help me to resolve those.
here is the composer.json
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"laravel/framework": "5.0.*",
"laracasts/flash": "^1.3",
"fzaninotto/faker": "~1.4",
"barryvdh/laravel-debugbar": "~2.0",
"orchestra/imagine": "~3.0",
"zendframework/zendsearch": "dev-master",
"mmanos/laravel-search": "dev-master",
"dimsav/laravel-translatable": "~5.0",
"twilio/sdk": "*",
"fillup/nexmo": "dev-master",
"guzzlehttp/log-subscriber": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1",
"illuminate/html": "~5.0"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/",
"Lib\\": "lib/"
}
},
"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"
}}
here is the screen shot
Plivo Sales Engineer here.
You should not use guzzlehttp/log-subscriber (it is depreciated as noted in the comments) but rather use any logger which implements a PSR-3 interface. See this SO post for how to do it with the builtin guzzle middleware and monolog or there is also the guzzle-log-middleware.
One other note: the latest version of plivo-php is 1.1.0. I'd encourage you to use that. It requires Guzzle v6.1.1.
According to plivo/plivo-php, it requires Guzzle v6.1.
guzzlehttp\log-subscriber is only compatible with Guzzle v4 and v5.
If you are attempting to log the Request or Response you can use GuzzleHttp\Middleware::log

Resources