I'm trying to deploy a symfony project following the steps:
./composer.phar update
php bin/console cache:clear
I've also tried to install manually doctrine driver ArrayCache running:
./composer.phar require doctrine/cache
The results is always the same and I end up with the following error:
# ./composer.phar update --no-interaction
[...]
Script cache:clear returned with error code 255
!!
!! In ContainerBuilder.php line 1089:
!!
!! Class Doctrine\Common\Cache\ArrayCache does not exist
!!
!!
!!
Script #auto-scripts was called via post-update-cmd
I'm new with symfony and I'm not able to understand why this class is missing.
I'm using the following versions:
"symfony/framework-bundle": "5.1.*",
"doctrine/doctrine-bundle": "^2.2",
Thanks in advance for your help.
I think you installed doctrine/cache 2.x version when installed "doctrine/doctrine-bundle": "^2.2",.
From github page:
This library is deprecated and will no longer receive bug fixes from the Doctrine Project. Please use a different cache library, preferably PSR-6 or PSR-16 instead.
So you have next options:
composer require doctrine/cache:^1.11
To use other lib for cache for example symfony/cache
After some time, I found a better solution:
composer require symfony/cache
then in php:
$config = new Configuration;
$queryCache = new PhpFilesAdapter('doctrine_queries'); $config->setQueryCache($queryCache);
$resultCache = new PhpFilesAdapter('doctrine_results', 0, $settings['cache_dir']); $config->setResultCache($resultCache);
$metaCache = new PhpFilesAdapter('doctrine_metadata', 0, $settings['cache_dir']); $config->setMetadataCache($metaCache);
I can now upgrade doctrine to the latest version.
This is somewhere along the line of another answer, but since the documentation is so poor (for non-Symfony user), adding a few lines of php can make all the difference!
Hope this helps some people. If this is for some reason not the best solution, I'm eager to hear.
For me the solution is to downgrade to doctrine 2.7.4.
Google'd around and it is obvious that Doctrine does not have its
documentation in order. I'll put on my todo-list to look for another
(3rd party) cache solution to replace the ArrayCache. I should have
done this earlier, since ArrayCache is not suitable for production.
Just hope Doctrine updates its documentation soon!
If I find an alternative, I'll post it here. Or perhaps someone else
beats me to it, I hope so!
I think it's established in the other answers that somewhere you are instantiating an instance of ArrayCache from the doctrine/cache package.
If you want equivalent functionality with doctrine/cache 2.x (where ArrayCache has been removed) you can do what doctrine/dbal itself will do.
I.e. instead of this...
$cache = new \Doctrine\Common\Cache\ArrayCache();
... you may instead do this (assuming you are comfortable introducing the symfony/cache package) ...
$cache = \Doctrine\Common\Cache\Psr6\DoctrineProvider::wrap(
new \Symfony\Component\Cache\Adapter\ArrayAdapter()
)
This is what Doctrine itself does as a fallback when ArrayCache does not exists and you do not otherwise specify a cache in dev-mode. You can see the logic for how Doctrine decides to instantiate a cache at \Doctrine\ORM\Tools\Setup::createCacheInstance.
(Note: Even when you do not specify a cache, Doctrine will instantiate one automatically -- it could be storing values in Redis without you even realising 😲)
To solve this problem, i first delete the composer.lock file, after, i installed composer with this following command: composer install and I installed the symfony cache dependency with this following command: composer require symfony/cach
->https://packagist.org/packages/symfony/cache
Deploying my Laravel 7 app in Heroku I get this error, it appears only in Heroku, not on my local box (localhost)
Class 'NumberFormatter' not found (View: ...)
Server Details:
Heroku
PHP 7.4.12
Laravel Framework 7.30.4
The NumberFormatter classDocs requires the PHP Internationalization extension (intl)Docs, and this extension is not available built-in on Heroku Heroku Built-in ExtensionsHeroku Docs.
Instead Heroku gives you permission to use optional extensionsHeroku Docs.
To make use of them you can either use the composer command to require it ("ext-intl"):
composer require ext-intl
Or you can manually add this to composer.json in the require sectionComposer Docs:
{
"require": {
"ext-intl": "*"
}
}
Commit the file and push the changes to Heroku. The error should be gone until you find the next missing class.
This is another example, why it is a good idea if you have a Composer based PHP project, to document the extensions in use as well in the composer.json file.
When the day comes, you have them documented in the Composer JSON already.
And systems like Heroku can benefit from it, too!
Am searching for PHP framework which supports PHP7 and latest php mongo driver (https://github.com/mongodb/mongo-php-driver) using 1.1.8 (https://pecl.php.net/package/mongodb)
I tried with codeignitor and fatfree but they seems to support old one. Any help is appreciated.
Thanks,
Zeeshan
If you are using codeignitor then you can install library through composer (you need to install composer first if you dont have)
Then go to your project directory through command line and run the following command
composer require "mongodb/mongodb=^1.0.0
It will install mongodb library in your vendor folder of your project.
Then you need to include following line where you want to use the library for eg you can include it on top of your controller or model.
require 'vendor/autoload.php';
I am trying to implement the Graphaware\neo4j client in php
neo4j-php-client
I ran composer to download the files to the working directory .www
and tried initiating the client using
require_once(BASEPATH.'vendor/autoload.php');
use GraphAware\Neo4j\Client\ClientBuilder;
$client = ClientBuilder::create()->addConnection('default', 'http://neo4j:myPassword#localhost:7474')->build();
I get this error.
<b>Fatal error</b>: Class 'GraphAware\Neo4j\Client\ClientBuilder' not found in <b>*path_to_my_www_dir\index.php*</b> on line <b>36</b><br />
Why am i seeing this?
I'm the maintainer of GraphAware Neo4j Client.
My bet is that you have been disturbed when reading the README of the repository.
The current master branch contains the code for 4.0#alpha, so if you ran in the command line composer require graphaware/neo4j-php-client chances are high that composer installed the last stable version in the 3.X series and thus the required class doesn't exist there.
I would suggest you try to install the alpha7 version of the client by running :
composer require graphaware/neo4j-php-client:^4.0#alpha
Let me know if you have other issues
We ran into the issue with neo4j-php-client not supporting PHP 5.5 as well. While the "correct" solution is to upgrade to a newer version of PHP, it isn't exactly the most convenient--especially if you just want to start evaluating this library. The only reason that PHP >= 5.6 is required is for Neo4j's bolt protocol, so as long as you stick to using the http protocol instead everything will work fine. In order to get composer to play nice though, you have to make a few changes to neo4j-php-client's composer.json:
Change "php": ">= 5.6" to "php": ">= 5.5"
Replace "graphaware/neo4j-bolt": "^1.5" with "graphaware/neo4j-common": "^3.0"
We ended up forking the library on Github and then updated our composer.json to use our modified version of neo4j-php-client. The relevant parts are:
{
...
"require": {
...
"graphaware/neo4j-php-client": "dev-OptionalBoltSupport"
},
...
"repositories": [
...
{
"type": "vcs",
"url": "https://github.com/wnielson/neo4j-php-client"
}
]
}
After doing this you can run composer update and neo4j-php-client should install fine.
You simply need to require vendor/autoload.php as said in documentation.
So require_once 'vendor/autoload.php'; will solve your problem.
The problem is that, even if you are using use ..., your php file didn't know anything about the php class file you're trying to create.
You need to include that file using include or require function.
When trying to run a migration I get the error Artisan migration
error:Class 'Doctrine\\DBAL\\Driver\\PDOMySql\\Driver' not found
I have read the questions here and also see the notes to add:
doctrine/dbal": "~2.3 in the requires section of composer.json
Github Bug Report
However, I don't understand what has happened. I created table a few days ago with no issue.
I can't figure out what to do after adding that dependency in composer.son.
I don't want to accidentally update any other packages.
The doctrine/dbal dependency needs to be added to your composer.json
composer require doctrine/dbal
For more information check laravel #Modifying Columns
In my case both composer install and composer install was not working giving a same error “Class 'Doctrine\DBAL\Driver\PDOMySql\Driver' not found”,
The changes that i made to make this workable are given below
composer.json file changed
"doctrine/dbal": "^3.0",
this changed with
"doctrine/dbal": "^2.0",
then run the command
composer update
You have to downgrade the current version, this is what worked for me:
composer require doctrine/dbal:2.*
If you using doctrine 3, downgrade to "doctrine/dbal": "^2.10.3"(I don't know does laravel updated migration tools for doctrine 3. If do, you should update laravel tools).
They renamed class and Doctrine\\DBAL\\Driver\\PDOMySql\\Driver not exists
Laravel
Who ever is facing this issue while having
doctrine/dbal": "3.0" aleady required:
downgrade it back to
"doctrine/dbal": "^2.10".
If you still face issues for example getting
Laravel\Passport\Bridge\AccessToken::__toString() must not throw an
exception
You should require a prev version of lcobucci/jwt. It just got auto updated to 3.4, which caused these issues for me.
Took me around 3-4 hours to track everything down to this.
Hope it helps someone else too.
composer require lcobucci/jwt 3.3.3
# For Laravel 6x/7x:
composer require doctrine/dbal:"^2.0"
# For Laravel >= 8x:
composer require doctrine/dbal
As already said, use composer require doctrine/dbal, if for whatever reason that doesn't work, use a lower version like composer require doctrine/dbal:^2.12.1 and then run composer dumpautoload -o.
Run
composer update
It will install your missing packages like PDOMySql.
Or
Delete vendor folder and run
composer install
This message shows up if you want to edit column in a database.
To solve it do:
add doctrine/dbal dependency to composer.json
and use the composer require doctrine/dbal command
In my case, it was due to the version of php that did not meet the necessary requirements for that version of the package.
So, updating to any previous version is not the solution, you have to look at the requirements of each version of the package and confirm that your project complies with them.
Here the specification of the requirements: https://packagist.org/packages/doctrine/dbal#3.1.3
And the command to update the library would be:
composer require doctrine/dbal:number_of_your_indicated_version
For example:
composer require doctrine/dbal:^2.13.5
Before modifying a column, be sure to add the doctrine/dbal dependency to your composer.json file. The Doctrine DBAL library is used to determine the current state of the column and create the SQL queries needed to make the specified adjustments to the column:
composer require doctrine/dbal
If you are using laravel 7 then please downgrade the "doctrine/dbal"
From
doctrine/dbal:"^3.1"
To
doctrine/dbal:"^2.0"
and then run
composer update
It works for me
just run
composer update
worked for me Laravel 8
I had the same problem with Laravel 8.
composer require doctrine/dbal
composer update
didn't help me to solve the issue.
I used DB::statement('SQLQuery') to solve the issue.
I used below code to rename the column.
public function up()
{
Schema::table('customer_profile', function (Blueprint $table) {
// $table->renameColumn('user_type_id','plan_id');
});
DB::statement('ALTER TABLE `customer_profile` CHANGE `user_type_id` `plan_id` BIGINT(20) NOT NULL;');
}
Can you share your current composer.json?
After composer.json update, you can execute composer install. It won't update existing packages (because of generated composer.lock), it'll only install new ones.
What has changes since your last migration?
It's the same project in the same directory? If so, it should be there.
OK thanks so much for the help.
Stupidly, I had read that to do some other operations, that missing driver is called and I had tried to run a migration the other day to change a column name and what I completely forgot was that subsequent migrate runs are trying to still run that bad one. Once i remembered and deleted the update column name migration, my add table migration ran fine. With a project due in a few weeks, no package updates for me!!
I saw this:
To rename a column, you may use the renameColumn method on the Schema builder. Before renaming a column, be sure to add the doctrine/dbal dependency to your composer.json file:
it maybe work.
if you are using PhpStorm editor for your project open Terminal tab and run this command:
composer require doctrine/dbal
also you can open command window in root of your project and run that command.