Composer.phar update now results in an ErrorException for MonologBundle - symfony

symfony/symfony v2.2.0
monolog/monolog v1.4.1
After running composer.phar update yesterday, monolog was updated; running the same command today results in the following error message:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Generating autoload files
[ErrorException]
Warning: constant(): Couldn't find constant Monolog\Logger::DEBUG in [path]\vendor\symfony\monolog-bundle\Symfony\Bundle\MonologBundle\DependencyInjection\MonologExtension.php line 109
The (i think) relevant part of config_dev.yml
monolog:
handlers:
main:
type: stream
path: %kernel.logs_dir%/%kernel.environment%.log
level: debug
firephp:
type: firephp
level: info
Did something change that requires additional configuration, or is something else happening ?

Monolog recently switch to PSR-4 compatible autoloading. Possibly, the
version of Composer you're running is too old for that. Please run
composer self-update first and try to update your dependencies again.

Sounds like the update didn't go well - do you have a Logger class in vendor/monolog/monolog/src/Monolog/Logger.php? If not I would suggest deleting the vendor/monolog dir and running composer install to get it back.

I had this same thing, but for Laravel.
I solved it by creating the app/storage folder and all it's sub-folders and files.
I get them by creating a new empty project, and just a copy-paste !
Woking now...
Here is the file structure:
app/storage/cache
app/storage/logs
app/storage/meta
app/storage/sessions
app/storage/views
You can ignore this folder for your repository.

Related

Symfony: Loading .env.test files

I thought this PR fixed the issue I am having - but I have this patch and it's still not working as I expected - what am I missing or mis-understanding?
https://github.com/symfony/symfony/pull/28533
I have created a .env.test with the following:
DATABASE_URL_TEST=mysql://apps:#localhost:3306/mydb_test
Then I dropped a doctrine.yaml inside the config/packages/test directory.
Symfony v4.2.3
However when I run this command from CLI:
APP_ENV=test bin/console doctrine:database:create --env=test
I am getting an error:
Environment variable not found: "DATABASE_URL_TEST".
Clearly the .env.test file is not being loaded - how do I get a specific environment configuration file to load - other than .env???
If indeed your application was a Symfony 3.x application at some point, what I would guess is that, during the upgrade process, those two lines out of the UPGRADE procedure were missed:
Then, upgrade the contents of your console script and your front
controller:
bin/console:
https://github.com/symfony/recipes/blob/master/symfony/console/3.3/bin/console
public/index.php:
https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/3.3/public/index.php
Indeed, it seems like bin/console have been changed recently to reflect the adaptation done on the DotEnv component: https://github.com/symfony/recipes/commit/3e471cbc7d359b3ab245f3b0748d698e8d29692c#diff-2af50efd729ff8e61dcbd936cf2b114b
Mind that you'll also need https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/4.2/config/bootstrap.php
I had a very similar problem. My issue was that my phpunit.xml.dist was pointing to the wrong bootstrap file:
Previously:
bootstrap="vendor/autoload.php"
Changed to:
bootstrap="tests/bootstrap.php"

howto fix composer.json in forked symfony bundle

I'm trying to install symfony-cmf/routing-auto version 2.0.0-RC1 , it requires jms/metadata:1.5.* which is working under Symfony 2x.
My current project works on Symfony 3.3.x which makes this bundle unable to install, so I made a fork on github, changed req. to jms/metadata:1.6.*
and added one line:
"replace": "symfony-cmf/routing-auto:2.0.0-RC1",
in order to test if it will work and I used in console:
composer require mkoniarz/routing-auto:dev-master
but then I got error:
Reading composer.json of mkoniarz/routing-auto (dev-master) Skipped branch dev-master, Invalid argument supplied for foreach()
What else I should fix to get this fork installed by composer?
PS my composer is up to date.
Did you try to remove the composer.json file ? I'd an similar error, i think it can be resolve your problem.
Or you should to try :
composer require symfony-cmf/routing-auto
always check composer.json:
composer.phar validate
then commit if valid :)
error was in "replace" line:
"replace": "symfony-cmf/routing-auto:2.0.0-RC1",
should be:
"replace": { "symfony-cmf/routing-auto":"2.0.0-RC1" },

class PHPUnit\Framework\ExpectationFailedException not found

when I try to run a failed test with this command :
./vendor/bin/phpunit
I get this Fatal Error :
PHPUnit 5.7.20 by Sebastian Bergmann and contributors.
PHP Fatal error: Class 'PHPUnit\Framework\ExpectationFailedException'
not found in /var/www/zend/vendor/zendframework/zend-
test/src/PHPUnit/Controller/AbstractControllerTestCase.php on line 444
Your version of phpunit is probably too old for your version of Zend. The class PHPUnit\Framework\ExpectationFailedException have been renamed in PhpUnit 6.X from PHPUnit_Framework_ExpectationFailedException to ExpectationFailedException
Please check your PhpUnit version: phpunit --version, it should be 6.X. Update it to the last version to avoid this error.
This is "fixed" by a script in Zend\Test called phpunit-class-aliases.php but it's not configured properly IMHO since it's in the autoload-dev section (meaning it doesn't propagate out to other projects.)
So, in your project composer.json, do something like this:
"autoload-dev": {
"files": [
"vendor/zendframework/zend-test/autoload/phpunit-class-aliases.php"
]
},
Then composer install
N.B. Zend\Test has a pull request that fixes this very thing, but they're saying it's PHPUnit's fault (Shame on you PHPUnit 4 for... idunno... having the wrong class name according to Zend\Test) So, I've done it instead: composer require illchuk/phpunit-class-aliases
This is a configuration flaw in zend-test. It consumes classes from Phpunit 6 but per it's Composer requirements, Phpunit before that version are OK to require:
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0",
Most likely as your system because of the PHP version does not satisfy the requirements of Phpunit 6, the next lower version was installed.
As the code in the base test case (https://github.com/zendframework/zend-test/blob/master/src/PHPUnit/Controller/AbstractControllerTestCase.php#L444) makes use of Phpunit 6 classes, I strongly assume that when the configuration flaw is made aware to the Zend-Test project, you won't be even able to install on your system any longer.
Therefore upgrade to a recent PHP version and then run
composer update
If you're stuk with the PHP version, downgrade zend-test to a version that supports an older Phpunit version. I don't know that project well, so it's just a suggestion, I don't know if such a version exists or can't even recommend one.
I filed a report, perhaps using that one class was an oversight or there is a less hard way to resolve the dependency: https://github.com/zendframework/zend-test/issues/50

Installing EWZRecaptchaBundle in Symfony2

I'm using symfony 2.4.0, and I want to install the EWZRecaptchaBundle to add a captcha to my forms, so I added this line to composer.json
"require": {
//...
"excelwebzone/recaptcha-bundle": "2.0.*"
//...
}
And I run this command
composer update
But it doesn't install the bundle successfully, and this is the error message I get, in the command
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package excelwebzone/recaptcha-bundle could not be found in
any version, there may be a typo in the package name.
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your min
imum-stability setting
see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.
Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common
problems.
For the record, this is the Github link to the bundle I want to install :
https://github.com/excelwebzone/EWZRecaptchaBundle
Any idea??
Notes:
I use the command line as an Administrator.
I tested also with this line : ""excelwebzone/recaptcha-bundle": "dev-master"
The same result when I set minimum stability setting to : "dev" or "stable"
Try to use this require:
"excelwebzone/recaptcha-bundle": "dev-master"
Because 2.0.x-dev are in development now. or use old stable version:
"excelwebzone/recaptcha-bundle": "v1.0.0"
Victor you are completely right. However some might still encounter issues with the versioning.
You will still have an issue unless you use the exact 1.0 version.
So after doing the require:
composer require "excelwebzone/recaptcha-bundle"
you will have do add the version 1.0 like:
Please provide a version constraint for the excelwebzone/recaptcha-bundle requirement: 1.0.*

How to install a Symfony 2.0 Bundle from Zip file

I tried installing the FixturesBundle as described in http://symfony.com/doc/2.0/bundles/DoctrineFixturesBundle/index.html but my proxy wont let me out.
So I went to https://github.com/doctrine/data-fixtures and download a zip from the latest commit.
I unzipped into the vendor directory and renamed it to doctrine-fixures. I edited the autoload.php and AppKernel.php files as described in the tutorial.
When I run:
php app\console doctrine:fixtures:load
I get the following message:
PHP Fatal error: Class 'Symfony\Bundle\DoctrineFixturesBundle\DoctrineFixturesB
undle' not found in C:\NetbeansProjects\route_rest_service\app\AppKernel.php on
line 20
Fatal error: Class 'Symfony\Bundle\DoctrineFixturesBundle\DoctrineFixturesBundle
' not found in C:\NetbeansProjects\route_rest_service\app\AppKernel.php on line
20
Is there a way to run the installation of bundle pointing it to a zip file?
I´m running Symfony 2.0.9 on Windows 7.
Seems like the doctrine bundle has been moved outside of Symfony scope back to Doctrine.
Please, use https://github.com/doctrine/DoctrineFixturesBundle
I had the same problem and this is how i successfully solved it. I started to download this files data-fixtures and DoctrineFixturesBundle, unzipped both into /vendor/doctrine and created this folder structure:
vendor
- doctrine
- doctrine-fixtures-bundle
- Doctrine
- Bundle
- FixturesBundle
DoctrineFixturesBundle.php
..other files...
vendor
- doctrine
- data-fixtures
- lib
- test
composer.json
..other files...
Then i edited the AppKernel.php and added
public function registerBundles(){
.....
new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
.....
}
Edited the composer.json located in the root of the project and added this 2 lines:
"Doctrine\\Bundle\\FixturesBundle": "vendor/doctrine/doctrine-fixtures-bundle",
"Doctrine\\Common\\DataFixtures": "vendor/doctrine/data-fixtures/lib"
Mine, now look like this:
{
"autoload": {
"psr-0": {
"": "src/",
"Doctrine\\Bundle\\FixturesBundle": "vendor/doctrine/doctrine-fixtures-bundle",
"Doctrine\\Common\\DataFixtures": "vendor/doctrine/data-fixtures/lib"
}
}
}
afterwards execute composer dump-autoload -o to recreate the classmap. All this was thanks to the users Wouter J and nifr that answered my question How to install DoctrineFixturesBundle offline
Happy coding!
Yes, it's true that Doctrine is being moved away from the Symfony namespace (see here).
So if you're using the Symfony standard distribution you download from the website (without using git), and you want to have the FixturesBundle installed manually, you have to download the doctrine-fixtures library from here, extract the zip into
YourProject/vendor/doctrine-fixtures
Download the FixturesBundle from here, and extract it in
YourProject/vendor/bundles/Doctrine/Bundle/FixturesBundle
Then you have to register the library's namespace, do it by adding
'Doctrine\\\\Common\\\\DataFixtures' => \__DIR\__.'/../vendor/doctrine-fixtures/lib',
in your autoload.php.
In addition, you'll have to register the Doctrine's namespace, because some part of your application will be using the DoctrineBundle shipped from the Symfony namespace, but the new downloaded FixturesBundle will be using the new Doctrine's namespace, so to make it work, in your autoload.php add the following line (taking care you do it before the Doctrine namespace, remember that more specific rules go first!)
'Doctrine\\\\Bundle' => \__DIR\__.'/../vendor/bundles',
So all you have to do now is to register the new bundle in your AppKernel.php writing
new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),

Resources