I am new to Symfony and I was assigned a Symfony 2 project.Now I am facing some problem with app/console server:run.
The project is a working system, therefore the problem should be because of my limited knowledge in Symfony framework.
this is what I keep getting
proc_open() : CreateProcess failed, error code - 267 in C:\xampp\htdocs\xxx\vendor\symfony\symfony\src\Symfony\Component\Process\Process.php on line 246.
line 246 is this part
$this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $this->env, $this->options);
I have tried changing the $this->cwd to "C:/xampp/htdocs/xxx", it can run but it will have another problem which is after I visit localhost:8000, it shows this
Warning: require(app_dev.php): failed to open stream: No such file or directory in C:\xampp\xxx\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Resources\config\router_dev.php on line 30
Fatal error: require(): Failed opening required 'app_dev.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\xxx\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Resources\config\router_dev.php on line 30
Any ideas what is wrong?
EDIT:
I have updated all my files as suggested my Matteo, a few issues came up with the vendors and I have solved it for new (hopefully). However now I am stuck at another problem which is this
The given document root directory "C:/xampp/htdocs/xxx/app/../web" does not exist.
As mentioned in the comments, I do not have a folder called "web". It was renamed to public. I have already changed the composer.json but it does not seem to do anything.
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "~2.4",
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "~1.2",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~2.3",
"sensio/framework-extra-bundle": "~3.0",
"sensio/generator-bundle": "~2.3",
"incenteev/composer-parameter-handler": "~2.0",
"richsage/rms-push-notifications-bundle": "dev-master",
"friendsofsymfony/user-bundle": "~1.3",
"ircmaxell/password-compat": "~1.0.3"
},
"scripts": {
"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"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": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
]
},
"config": {
"bin-dir": "bin"
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "public",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "2.4-dev"
}
}
}
If I type app/console --version in cmd, it shows Symfony version 2.6.1 - app/dev/debug
Please help me out.
It's a bug as described here. It is resolved in the current framework version (2.6.1).
So the solution is to upgrade to the current version. You can verify in the UPGRADE files on the github repo is something is changed but there anren't BC (Break Compatibility).
In addition, your current framework version (2.4.2) is out of support so is a good moment to do this task.
In general is a good practice to upgrade to the last stable version of the framework. Take a look at the sf2 release roadmap for the release process and for the end of support of the various framework release.
Hope this help
Related
I updated my vendors for a Symfony 2.8 project and suddenly the login page isn't loading – instead I get this:
Error: Call to a member function has() on a non-object in
vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php
at line 184
"name": "hazardlog",
"license": "proprietary",
"type": "project",
"autoload": {
"psr-4": {
"": "src/"
},
"classmap": [
"app/AppKernel.php",
"app/AppCache.php"
]
},
"repositories": [
{
"type": "package",
"package": {
"name": "jquery/jquery",
"version": "1.11.1",
"dist": {
"url": "https://code.jquery.com/jquery-1.11.1.js",
"type": "file"
}
}
}
],
"require": {
"php": ">=5.3.9",
"symfony/symfony": "2.8.*",
"doctrine/orm": "^2.4.8",
"doctrine/doctrine-bundle": "~1.4",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "~2.0",
"braincrafted/bootstrap-bundle": "~2.0",
"twbs/bootstrap": "3.0.*",
"jquery/jquery": "1.11.*",
"hwi/oauth-bundle": "^0.5.0",
"friendsofsymfony/user-bundle": "~2.0#dev",
"stephanecollot/datetimepicker-bundle": "dev-master"
},
"require-dev": {
"sensio/generator-bundle": "~3.0",
"symfony/phpunit-bridge": "~2.7"
},
"scripts": {
"symfony-scripts": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
],
"post-install-cmd": [
"#symfony-scripts"
],
"post-update-cmd": [
"#symfony-scripts"
]
},
"config": {
"bin-dir": "bin"
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
}
}
I have seen this sort of question several times but I could not find one with an accepted answer and explanation. So here goes.
The basic problem lies with:
"friendsofsymfony/user-bundle": "~2.0#dev",
Back when Symfony 2.8/3.0 was first released, the stable 1.x version of FOSUserBundle no longer worked. The 2.x version has been in development for years with no actual road map in sight for when it would be stabilized. So the development branch was hacked up to get it working. And folks had no choice but to use it which of course is dangerous because you never know when a development change might in fact break your code.
Time went by and eventually a stable 2.x version of the FOSUserBundle was released. However, quite a few developers never got around to updating their dependencies and continued to use the master branch.
Fast forward to the present. The release of Symfony 4 has now triggered a fair amount of development in the master branch. Development which is introducing breaking changes to existing 2.8 (and probably 3.0) code.
The bottom line is to use a stable branch with:
"friendsofsymfony/user-bundle": "~2.0",
followed by a composer update.
For those using Symfony 3.2, it looks like version "~2.1" throws same error along with the OP's version "~2.0#dev".
This worked:
"friendsofsymfony/user-bundle": "2.0"
Keeping it at 2.0 did the trick for me.
had a problem like this here but solved,i just did the opposite of this.
i had:
"friendsofsymfony/user-bundle": "^2.1",
in my composer.json file which give me a Call to a member function has() on null error to solve this i Actually add "#dev it became:
"friendsofsymfony/user-bundle": "^2.1#dev",
then updated my composer with :
composer update
I've recently installed symfony 3, and while it seems to be working okay, I noticed that my error logs keep filling up with the following message.
[10-Jan-2016 01:03:11 America/Chicago] PHP Warning: Module 'intl' already loaded in Unknown on line 0
After looking into it, I set these in my composer.json file to see if it would help.
"symfony/intl": "^3.0.1",
"symfony/polyfill-intl-icu": "^1.0"
but I still see the errors after I do anything with the page, like refresh it, or try to enter in my login etc...
The full composer.json is below with my domain name replaced with example.com for security reasons.
{
"name": "root/example.com",
"license": "proprietary",
"type": "project",
"autoload": {
"psr-4": {
"": "src/"
},
"classmap": [
"app/AppKernel.php",
"app/AppCache.php"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"require": {
"php": ">=5.5.9",
"symfony/symfony": "3.0.*",
"doctrine/orm": "^2.5",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/doctrine-cache-bundle": "^1.2",
"symfony/swiftmailer-bundle": "^2.3",
"symfony/monolog-bundle": "^2.8",
"sensio/distribution-bundle": "^5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "^2.0",
"symfony/intl": "^3.0.1",
"symfony/polyfill-intl-icu": "^1.0"
},
"require-dev": {
"sensio/generator-bundle": "^3.0",
"symfony/phpunit-bridge": "^2.7"
},
"scripts": {
"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
],
"post-update-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
]
},
"extra": {
"symfony-app-dir": "app",
"symfony-bin-dir": "bin",
"symfony-var-dir": "var",
"symfony-web-dir": "web",
"symfony-tests-dir": "tests",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
}
}
}
Also I tried following the advice on a question similar to mine here (Problems installing Symfony 2.4.1 lib-icu 4.4 dependency), but when I tried to set "symfony/icu": "1.1.*", composer refused to do it because I'm using symfony 3...
I'm not even sure if my issues are same as his.
I'm using WHM/Cpanel on Centos Linux Server in case there is any UNIX commands I need to run to solve this.
I believe I have installed the intl extension already via the WHM control panel as well, but I'm not 100% sure I did this correctly either. I've attached an image of how it looks in my control panel.
I've also tried following instructions here (http://symfony.com/doc/current/components/intl.html)
How do I get rid of the error message?
I believe this is not Symfony related.
Usually the case is your installed PHP version compiled with --with-intl option (intl built-in) and you have also installed intl extension.
Try to disable/ uninstall the intl extension and test if you can still use symfony/intl features without issues.
SensioDistributionBundle before v5.0.17 creates this kind of errors when used with Composer v1.3 (more details).
Check if you could be affected:
composer --version && composer show | grep distribution-bundle
If so, get rid of the problem by updating SensioDistributionBundle to the latest version:
composer update sensio/distribution-bundle
I have a Symfony 2 project and I cant rename the web dir for some reasons. I am trying to rename it to public.
According to the manual, I am suppose to change the composer.json and make sure the links in app.php and app_dev.php is correct.
But when I run app/console server:run, it shows
The given document root directory "C:/xampp/htdocs/xxx/app/../web" does nto exists.
I have changed the composer.json, run composer install and composer update but still no luck. Here is my composer.json , as you can see I have already added "symfony-web-dir": "public" to the file.
If I rename my public folder to web, then everything is fine, but for certain reasons I can't do that.
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "~2.4",
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "~1.2",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~2.3",
"sensio/framework-extra-bundle": "~3.0",
"sensio/generator-bundle": "~2.3",
"incenteev/composer-parameter-handler": "~2.0",
"richsage/rms-push-notifications-bundle": "dev-master",
"friendsofsymfony/user-bundle": "~1.3",
"ircmaxell/password-compat": "~1.0.3"
},
"scripts": {
"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"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": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
]
},
"config": {
"bin-dir": "bin"
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "public",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "2.4-dev"
}
}
}
You can indeed change the name of the 'web' directory, but the server:run command does not expect this. As you can see in the ServerRunCommand source code (on line 77), the 'web' directory is hard-coded in there.
However, you should be able to solve this by simply providing the --docroot option when running the command:
bin/console server:run --docroot=C:/xampp/htdocs/xxx/public
(replace bin/console with the location of the console, which may be app/console if you are using the Symfony 2 structure)
I have installed symfony2 and i have ensured the application has been installed correctly and i am trying to create a bundle for my project and i seem to be getting this message and i have edited the composer.json manually and added the correct bundle to the file:
Generating the bundle code: OK
Checking that the bundle is autoloaded: FAILED
Confirm automatic update of your Kernel [yes]? yes
Enabling the bundle inside the Kernel: OK
Confirm automatic update of the Routing [yes]? yes
Importing the bundle routing resource: OK
i have ensured composer has been configured correctly and i have removed previous namespaces from appkernel.php and routing.yml any help would be much appreciated.
this is my composer.json file:
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": {
"Acme": "src/"
}
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "~2.4",
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "~1.2",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~2.3",
"sensio/framework-extra-bundle": "~3.0",
"sensio/generator-bundle": "~2.3",
"incenteev/composer-parameter-handler": "~2.0"
},
"scripts": {
"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"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": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
},
"config": {
"bin-dir": "bin"
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "2.4-dev"
}
}
}
I also encountered the same problem while generating my first bundle. I did the following things:
1. Make sure you have Composer installed before generating a bundle.
2. If the same failure message occurs on generating bundles, then in the terminal type this in your project directory $ sudo composer dumpautoload -o.
This will run your application.
Just getting into Symfony2 and I wanted to use the CMF bundle.
I am following the cookbook here:
http://symfony.com/doc/current/cmf/cookbook/editions/cmf_core.html
When running
composer.phar update
I am getting this error:
[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
When the dynamic router is enabled, you need to either enable one of the persistence layers or set the cmf_routing.dynamic.route_provider_service_id option
What is the proper setting for route_provider_service_id? I cannot find any docs on this.
config.yml
# CMF config
cmf_routing:
chain:
routers_by_id:
cmf_routing.dynamic_router: 200
router.default: 100
dynamic:
enabled: true
route_provider_service_id: ~
sonata_block:
default_contexts: [cms]
Here is my composer.json file:
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/" }
},
"minimum-stability": "dev",
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.3.*",
"doctrine/orm": ">=2.2.3,<2.4-dev",
"doctrine/doctrine-bundle": "1.2.*",
"twig/extensions": "1.0.*",
"symfony/assetic-bundle": "2.3.*",
"symfony/swiftmailer-bundle": "2.3.*",
"symfony/monolog-bundle": "2.3.*",
"sensio/distribution-bundle": "2.3.*",
"sensio/framework-extra-bundle": "2.3.*",
"sensio/generator-bundle": "2.3.*",
"incenteev/composer-parameter-handler": "~2.0",
"jackalope/jackalope-doctrine-dbal": "dev-master",
"doctrine/phpcr-bundle": "1.0.*",
"doctrine/phpcr-odm": "1.0.*",
"symfony-cmf/symfony-cmf": "1.0.*"
},
"scripts": {
"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"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": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
]
},
"config": {
"bin-dir": "bin"
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "2.3-dev"
}
}
}
If anyone could just shine some light on these cmf_routing settings to get a clean update from composer would be great.
One thing that I find frustrating with this new Sym2 method is it seems every bundle you need, comes with another required bundle, compiling your probabilities for errors and confusion.
UPDATE
I have looked at the Dynamic configuration here:
http://symfony.com/doc/master/cmf/reference/configuration/routing.html#dynamic
It says this about route_provider_service_id:
route_provider_service_id
type: string
When none of the persistence layers is enabled, a route provider service must be provided in order to get the routes. This is done by using the route_provider_service_id setting.
I understand if i do not set persistence, I should add this setting. I know the setting should be a string. But I don't know what the service_id actually is, so I don't know what the setting could be. Perhaps I am still unclear on what I am doing with the dynamic router.
I was able to fix this by enabling persistence.phpcr and giving the manager_name: null
Removed the error, but it could be that defining the manager_name is an important step in getting the CMF off the ground.
You need to configure the route provider. Otherwise the router won't know how to load routes. The idea of the dynamic router is that you can load routes from the database, so you need to tell it how to load them. you can either enable persistence.phpcr or persistence.orm, or provide your own service.
There is an introduction to the cmf routing here
http://symfony.com/doc/master/cmf/book/routing.html
And more details here http://symfony.com/doc/master/cmf/bundles/routing/dynamic.html (i just clarified the thing with the route provider a bit more, as i realized it was not very explicit).
The configuration reference for routing is here:
http://symfony.com/doc/master/cmf/reference/configuration/routing.html#dynamic