I am playing around with Lumen, I installed it via Lumen installer. After I do composer install, I try to use artisan but it throws the following error:
ReflectionException: Class redis does not exist in Container.php on line 752
My composer.json:
"require": {
"php": ">=7",
"ext-pdo_pgsql": "*",
"ext-soap": "*",
"guzzlehttp/guzzle": "^6.3",
"laravel/lumen-framework": "5.5.*",
"laravel/tinker": "^1.0",
"vlucas/phpdotenv": "~2.2"
},
"require-dev": {
"barryvdh/laravel-ide-helper": "^2.4",
"doctrine/dbal": "^2.5"
},
Thanks in advance.
I had the same.
Solution:
composer require illuminate/redis
Register it in bootstrap/app.php by calling
$app->register(Illuminate\Redis\RedisServiceProvider::class);
in the file, under Register Service Providers.
From this aricle.
From Lumen's official documentation at https://lumen.laravel.com/docs/7.x/cache :
Redis Support:
Before using a Redis cache with Lumen, you will need to install the illuminate/redis package via Composer. Then, you should register the Illuminate\Redis\RedisServiceProvider in your bootstrap/app.php file:
$app->register(Illuminate\Redis\RedisServiceProvider::class);
If you have not called $app->withEloquent() in your bootstrap/app.php file, then you should call $app->configure('database'); in the bootstrap/app.php file to ensure the Redis database configuration is properly loaded.
Related
I have this error while using the MediaLibrary package
Interface 'Spatie\MediaLibrary\HasMedia' not found
Trait 'Spatie\MediaLibrary\InteractsWithMedia' not found
My project details :-
php : 7.3.22
laravel : 7.28.3
I have tried follow the documentation v7 and also run the command below
composer require spatie/laravel-medialibrary
Other than that, I have also checked on other post which I have follow most of the steps but still getting back the same error
composer.json
"require": {
"php": "^7.2.5",
"fideloper/proxy": "^4.2",
"fruitcake/laravel-cors": "^1.0",
"guzzlehttp/guzzle": "^6.3",
"laravel/framework": "^7.0",
"laravel/tinker": "^2.0",
"laravelcollective/html": "^6.2",
"spatie/laravel-activitylog": "^3.16",
"spatie/laravel-medialibrary": "^7.19"
},
Model
use Illuminate\Database\Eloquent\Model;
use Spatie\Activitylog\Traits\LogsActivity;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
class Applicant extends Model implements HasMedia
{
use LogsActivity, InteractsWithMedia;
}
Make sure to follow the documentation for the specific version of Laravel-medialibrary that you are using. In your case version 7. It looks like you were following the version 8 documentation.
In version 7, the trait is Spatie\MediaLibrary\HasMedia\HasMediaTrait instead of Spatie\MediaLibrary\InteractsWithMedia. And the interface is Spatie\MediaLibrary\HasMedia\HasMedia instead of Spatie\MediaLibrary\HasMedia.
If you want to use version 8 instead, change your requirements to "spatie/laravel-medialibrary": "^8.0" and then run composer update.
BarryVdh's ide-helper has been sucessfully installed to my Laravel project as the composer.json desribes:
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*",
...
},
"require-dev": {
...
"barryvdh/laravel-ide-helper": "^2.1",
"doctrine/dbal": "^2.9"
},
Added to providers in app/config as:
'providers' => [
...
Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
],
I assume it partially works as the command php artisan ide-helper:meta generates .phpstorm.meta.php in the root folder, but the php artisan ide-helper:generate command fails with the following simple error:
[Symfony\Component\Debug\Exception\FatalThrowableError]
Parse error: syntax error, unexpected end of file
If I try to generate model info with the command php artisan ide-helper:models, asks for overwrite models or to write to _ide_helper_models.php instead, 'no' chosen, it fails and throws the same error above. However, if I add a model to the command (eg. php artisan ide-helper:models Order ), after choosing 'no' for overwrite the ide-helper generates the _ide_helper_models.php file without any relevant content, just the default comment block.
What to check in this case?
(phpStorm IDE, win10, Laravel 5.1, Xampp, PHP7)
After todays update of composer dependencies (with composer update command) my Yii2 application became broken - It throws Unknown Method – yii\base\UnknownMethodException: Calling unknown method: yii\web\UrlManager::addRules()
After inspecting vendor/yiisoft/yii2/web/UrlManager.php file I found that there is no method addRule.
And the whole entire class UrlManager is different from the class in the repository.
My composer.json:
"minimum-stability": "dev",
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": "*",
"yiisoft/yii2-bootstrap": "*",
"yiisoft/yii2-swiftmailer": "*",
"yiisoft/yii2-gii": "2.0.0-beta",
"claudejanz/yii2-mygii": "*",
"kartik-v/yii2-grid": "dev-master",
"kartik-v/yii2-builder": "dev-master",
"2amigos/yii2-switch-widget": "*",
"yiisoft/yii2-jui": "*",
"DsXack/yii2-underscore": "*",
"2amigos/yii2-editable-widget": "*",
"warrence/yii2-kartikgii": "*"
},
"require-dev": {
"yiisoft/yii2-codeception": "*",
"yiisoft/yii2-debug": "*"
},
I think they have changed the way some libraries are loaded through composer.
To solve it:
Add to composer.json
"extra": {
"asset-installer-paths": {
"npm-asset-library": "vendor/npm",
"bower-asset-library": "vendor/bower"
}
}
and run:
# php composer.phar global require "fxp/composer-asset-plugin:1.0.*#dev"
# php composer.phar update --dev
More info: Issue on Github and Issue on Github
Full credit to: #githubjeka and #SonicGD
Here is an explaination of why this happened:
I think this is again the composer dependency resolver doing unexpected things:
you require yiisoft/yii2 in your composer.json but do not have the composer asset plugin installed.
then the dependency resolver does not find packages with vendor bower-asset so it looks for other versions of yiisoft/yii2 that do not have conflict
The result is to install the beta version of yii2 to be installed
The correct solution as already mentioned is to install the composer-asset-plugin:
php composer.phar global require "fxp/composer-asset-plugin:1.0.*#dev"
It seems the update went totally wrong, since the files are different from the ones on github - several functions missing.
What i had to do to get "rid" of this error:
Copy the code from the repository in your local files:
https://github.com/yiisoft/yii2/blob/master/framework/web/UrlManager.php
https://raw.githubusercontent.com/yiisoft/yii2/master/framework/helpers/BaseHtml.php
This solved it for the moment for me.
Like ricardgf says, read this:
https://github.com/yiisoft/yii2/blob/master/docs/guide/start-installation.md
then run:
composer.phar global require "fxp/composer-asset-plugin:1.0.*#dev"
and
composer.phar update --prefer-source --no-interaction
ok I solved the problem installing yii2 in this way :
composer global require "fxp/composer-asset-plugin:1.0.*#dev"
composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic
Try to update your composer.json into following way:
"require": {
"yiisoft/yii2": "*"
},
in project directory, write this command-
php composer.phar update
I am trying to run Laravel 4 application in Google App engine. I am following this tutorial but the problem is that when I run it by using cmd
C:\Program Files (x86)\Google\google_appengine>python dev_appserver.py --skip_sdk_update_check=yes --port=8080
--admin_port=8000 --php_executable_path=C:\wamp\bin\php\php5.4.12\php-cgi.exe C:\laravel-test\laravel
it shows the following error:
Fatal error: Interface 'Illuminate\Session\SessionInterface' not found in C:\laravel-test\laravel\bootstrap\compiled.php on line 7301
compiled.php: http://laravel.io/bin/ekP5m
I Also got this error during update using composer.In the composer.json file. there should not include two require parts
ex : --- this is not working
"require": {
"laravel/framework": "4.0.",
"neoxia/laravel-openssl-encryption": "1.0."
},
"require": {
"evernote/evernote": "dev-master"
},
this will work
"require": {
"laravel/framework": "4.0.",
"neoxia/laravel-openssl-encryption": "1.0.",
"evernote/evernote": "dev-master"
},
please check your file and make sure about that i think this will work
I have been working on a project using Symfony 2.1 on my local machine. I have uploaded it to my server but when I try and install the vendor bundles using Composer, I'm getting a lot of dependency errors. Presumably this is something to do with the latest version of Symfony just being released and my composer.json file not specifying exact version numbers.
Is there any way I can quickly display the version numbers of everything on my local machine?
Here is my composer.json file (which worked fine until a few days ago):
{
"name": "symfony/framework-standard-edition",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.1.*",
"doctrine/orm": ">=2.2.3,<2.4-dev",
"doctrine/doctrine-bundle": "1.0.*",
"twig/extensions": "1.0.*",
"symfony/assetic-bundle": "2.1.*",
"symfony/swiftmailer-bundle": "2.1.*",
"symfony/monolog-bundle": "2.1.*",
"sensio/distribution-bundle": "2.1.*",
"sensio/framework-extra-bundle": "2.1.*",
"sensio/generator-bundle": "2.1.*",
"jms/security-extra-bundle": "1.2.*",
"jms/di-extra-bundle": "1.1.*",
"sonata-project/admin-bundle": "*",
"sonata-project/cache-bundle": "dev-master",
"sonata-project/doctrine-orm-admin-bundle": "dev-master",
"stof/doctrine-extensions-bundle": "1.1.x-dev",
"sonata-project/user-bundle": "dev-master",
"sonata-project/easy-extends-bundle": "dev-master",
"friendsofsymfony/user-bundle": "2.0.x-dev",
"friendsofsymfony/jsrouting-bundle": "*",
"liip/imagine-bundle": "*",
"simplethings/form-extra-bundle": "dev-master",
"antimattr/google-bundle": "dev-master",
"doctrine/doctrine-fixtures-bundle": "dev-master",
"genemu/form-bundle": "2.1.*",
"behat/behat": "2.4.*#stable",
"behat/mink": "1.4.*#stable",
"behat/symfony2-extension": "*#stable",
"behat/mink-extension": "*#stable",
"behat/mink-selenium2-driver": "*#stable",
"behat/mink-browserkit-driver": "*",
"liip/functional-test-bundle": "dev-master"
},
"scripts": {
"post-install-cmd": [
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
],
"post-update-cmd": [
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
]
},
"minimum-stability": "dev",
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web"
},
"config": {
"bin-dir": "bin/"
}
}
You can run composer show -i (short for --installed).
In the latest version just use composer show.
The -i options has been deprecated.
You can also use the global instalation of composer: composer global show
To list the globally installed composer packages:
composer global show -i
List installed dependencies:
Flat: composer show -i
Tree: composer show -i -t
-i short for --installed.
-t short for --tree.
ref: https://getcomposer.org/doc/03-cli.md#show
If you only want to check version for only one, you can do
composer show -- twig/twig
Note that only installed packages are shown by default now, and installed option is now deprecated.
The behaviour of this command as been modified so you don't have to pass the -i option:
[10:19:05] coil#coil:~/workspace/api$ composer show -i
You are using the deprecated option "installed".
Only installed packages are shown by default now.
The --all option can be used to show all packages.
Ivan's answer above is good:
composer global show -i
Added info: if you get a message somewhat like:
Composer could not find a composer.json file in ~/.composer
...you might have no packages installed yet. If so, you can ignore the next part of the message containing:
... please create a composer.json file ...
...as once you install a package the message will go away.
With composer-runtime-api 2.0+ there is a new InstalledVersions class with some static methods to see things programmatically.
For example:
// To list all packages (`string[]`)
\Composer\InstalledVersions::getInstalledPackages();
// To list every details of every packages
\Composer\InstalledVersions::getAllRawData();
More information: https://getcomposer.org/doc/07-runtime.md#installed-versions
If you want to install Symfony2.2, you can see the complete change in your composer.json on the Symfony blog.
Just update your file according to that and run composer update after that. That will install all new dependencies and Symfony2.2 on your project.
If you don't want to update to Symfony2.2, but have dependency errors, you should post these, so we can help you further.
Is there a way to get it via $event->getComposer()->getRepositoryManager()->getAllPackages()