laravel Call to undefined function get() - laravel

when i run a command in laravel project :
php artisan optimize
[Symfony\Component\Debug\Exception\FatalErrorException]
Call to undefined function get()
Script php artisan optimize handling the post-update-cmd event returned with an error
[RuntimeException]
Error Output:
and
php artisan clear-compiled
[Symfony\Component\Debug\Exception\FatalErrorException]
Call to undefined function get()
and
php artisan optimize --force
[Symfony\Component\Debug\Exception\FatalErrorException]
Call to undefined function get()
and
{
composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Removing barryvdh/laravel-ide-helper (v2.1.4)
- Removing symfony/class-loader (v3.1.0)
Writing lock file
Generating autoload files
Illuminate\Foundation\ComposerScripts::postUpdate
php artisan optimize
[Symfony\Component\Debug\Exception\FatalErrorException]
Call to undefined function get()
Script php artisan optimize handling the post-update-cmd event returned with an error
[RuntimeException]
Error Output:
}
and my composer.json is
{
"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": "5.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": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist"
}
}
so, what's wrong is it,and how can i fix it? thanks?

This error also comes when you did an error in creating a route.
Instead of Route::get(...) you may have put Route:get(...), So just check in your route or Controllers files

You're using get() method in a wrong way somewhere in your app (model or controller). Fix it and all commands will work again.
If you want more help, please post your recently added code which uses get() method.

Related

ReflectionParameter::getClass() method deprecated in php 8.0.1

I am getting this error:
PS C:\Users\User\Desktop\jk> php artisan serve
PHP Fatal error: Uncaught ErrorException: Method ReflectionParameter::getClass() is deprecated in C:\Users\User\Desktop\jk\vendor\laravel\framework\src\Illuminate\Container\Container.php:788
Stack trace:
Composer.json
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": "^7.4|^8.0",
"laravel/framework": "5.4.*",
"laravelcollective/html": "^5.3.0",
"guzzlehttp/guzzle": "^6.3",
"doctrine/dbal": "^2.9"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "^9.3",
"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",
"platform": {
"php": "8.0.1"
}
}
}
Container.php Here some part of code
protected function resolveClass(ReflectionParameter $parameter)
{
try {
return $this->make($parameter->getClass()->name);
}
// If we can not resolve the class instance, we will check to see if the value
// is optional, and if it is we will return the optional parameter value as
// the value of the dependency, similarly to how we do this with scalars.
catch (BindingResolutionException $e) {
if ($parameter->isOptional()) {
return $parameter->getDefaultValue();
}
throw $e;
}
}
Method ReflectionParameter::getClass() is deprecated .i think is getclass method is deprecated in version 8.0.1nstead of this i trying to using ReflectionParameter::getType()like link but not working .and also members suggest this
Laravel app stopped working after upgrading to php 8 i tried this also but not working
because ReflectionParameter::getClass() is deprecated in php 8 .
solution go to
vendor\laravel\framework\src\Illuminate\Container\Container.php
and go to
protected function resolvePrimitive(ReflectionParameter $parameter)
and replace
$parameter->getClass()** with **$parameter->getType()->getName() .
Laravel 5.4 seems to have incorrect platform requirements. Specifically that it requires PHP version >= 5.6 however it has code that will not work in PHP 8. Since 5.4 is end of life I would not expect any official code changes to make it work for PHP 8 so you would either need to fork and maintain your own Laravel 5.4 branch that solves these problems or upgrade your Laravel version to one that supports PHP 8.
The first Laravel version that supports PHP 8 is Laravel 6
You can replace it with getType(), which the documentation suggest. You have to create your own ReflectionClass, from the ReflectionType. This should do the trick.
$reflectionClass = new ReflectionClass($reflectionParam->getType()->getName());
I have this sandbox, that helped me assure it was working as intended.
You might need to update your global composer.json with:
composer global update
I had some annoying issue so I hade to run:
composer global update --ignore-platform-reqs

Laravel composer update give error

I just update the compose and i found below error.
php artisan clear-compiled PHP Fatal error: Call to undefined method
Illuminate\View\Compilers\BladeCompiler::directive() in
/var/www/html/innomaid/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php
on line 213
[Symfony\Component\Debug\Exception\FatalErrorException]
Call to undefined method
Illuminate\View\Compilers\BladeCompiler::directive()
Script php artisan clear-compiled handling the post-update-cmd event returned with an error
[RuntimeException]
Error Output: PHP Fatal error: Call to undefined method
Illuminate\View\Compilers\BladeCompiler::directive() in
/var/www/html/innomaid/ve
ndor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on
line 213
Here is my composer code
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"laravel/framework": "5.0.*",
"illuminate/html": "5.*",
"barryvdh/laravel-dompdf": "0.6.*",
"tymon/jwt-auth": "0.5.*",
"gloudemans/shoppingcart": "~1.3",
"intervention/image": "^2.3"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1",
"zizaco/entrust": "dev-laravel-5"
},
"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"
}
}
Please help me to solve this error
update "zizaco/entrust": "dev-laravel-5" to "zizaco/entrust": "1.4.1"
Solve my problem.

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

Composer --> Package listed for update is not installed, ignoring

I am using Laravel 5.1 and trying to install a new package via composer. I am using following command.
composer require "matriphe/imageupload:5.1.*"
I am getting following error.
./composer.json has been updated
> php artisan clear-compiled
Package "matriphe/imageupload" listed for update is not installed. Ignoring.
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Writing lock file
Generating autoload files
> php artisan optimize
Generating optimized class loader
I also tried running
composer self-update
This is the message I received.
You are already using composer version f1aa655e6113e0efa979b8b09d7951a762eaa04c.
I have also tried updating composer dependencies for project via manually adding package name to composer.json and running.
composer update
and
partially updating via.
composer update "matriphe/imageupload:5.1.*"
Up until now I have installed other packages and all of them were installed except this one.
For me, it was simply a typo in the package name.
Update: I solved the issue in the most bizzare way possible.
I initially had following composer.json file when I ran the command
composer require "matriphe/imageupload:5.1.*"
and
composer require laravelcollective/html:~5.0
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*",
"matriphe/imageupload": "5.1.*",
"laravelcollective/html": "~5.0"
},
"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"
}
}
And got the error.
Package "matriphe/imageupload" listed for update is not installed. Ignoring.
and
Package "laravelcollective/html" listed for update is not installed. Ignoring
To solve it I manually added another require array in json added packages to be installed which is given below.
"require": {
"laravelcollective/html": "~5.0",
"matriphe/imageupload": "5.1.*"
}
My modified composer.json file look like this.
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*"
},
"require": {
"laravelcollective/html": "~5.0",
"matriphe/imageupload": "5.1.*"
},
"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"
}
}
and ran the following command.
composer update
It did the trick for me.

Fatal error after creating new Laravel 5 project

I created a brand new Laravel 5 application via laravel new mysite. When I open the site I see the following errors:
Notice: date_default_timezone_set(): Timezone ID '' is invalid in /mysite/storage/framework/compiled.php on line 1790
Fatal error: Call to undefined method Illuminate\Foundation\Bootstrap\ConfigureLogging::configureHandler() in /mysite/storage/framework/compiled.php on line 1656
Here is my composer.json:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"laravel/framework": "5.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've already ran composer update to make sure I have the latest dependencies, but I'm still getting the same error. Any ideas?
Edit: I'm using PHP 5.4
Edit 2: It works when running via php artisan serve but not when using my my dev box running apache to serve the site. So it could be a local php issue on that box.
I believe this issue has to do with your local server settings. I had the same issue on my local server and I set the value date.timezone in my php.ini

Resources