I am trying to do this:
c:\> php symfony configure:database "mysql:host=localhost;dbname=jobeet" root mYsEcret
This doesnt work for me because it says
Could not open input file
I thought I needed to add symfony-file located in C:\dev\sfprojects\jobeet\lib\vendor\symfony\data\bin\ to PATH, but this didn't do the trick. I tried to enter the whole path to the symfony-file like so:
c:\> php C:\dev\sfprojects\jobeet\lib\vendor\symfony\data\bin\symfony\ configure:database "mysql:host=localhost;dbname=jobeet" root mYsEcret
I get error Task configure:database not defined
What should I do in order to:
Be able to use the symfony keyword
rather than the whole path of the
file
Be able to run configure:database?
Thank you for your time.
Kind regards,
Marius
You need to be in the directory of your symfony project, in this case C:\dev\sfprojects\jobeet\.
"Because the symfony shortcut file is executable, Unix users can replace all occurrences of 'php symfony' by './symfony' from now on.
On Windows you can copy the 'symfony.bat' file to your project and use 'symfony' instead of 'php symfony":
http://www.symfony-project.org/jobeet/1_4/Doctrine/en/01#chapter_01_sub_application_creation
Related
any help please DB : XAMPP , logiciel : vscode
cake : The term 'cake' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At line:1 char:1
By default Powershell doesn't run commands from the current location, you'd for example have to lower protection by adding the directory to your path environment variable (which I wouldn't recommend). Alternatively you'd use .\ before the command, to make it clear that you want to run a command in the current directory, ie .\cake.
However you should not run cake from within the bin directory in the first place, you should run it from the root of your application, ie from within your cakephp directory, so that you'd use:
bin\cake bake
See also
Cookbook > Console Commands
Bake Cookbook > Code Generation with Bake
I'm looking through the documentation, but I'm not seeing any option to change the working directory used when running tests.
I'm using PhpUnit as it's included in Laravel. I want to be able to run vendor/bin/phpunit from my project's root directory, and have it run using the /public directory as the working directory.
I tried running ../vendor/bin/phpunit from the /public, but since the phpunit.xml file isn't in the public directory and I don't want to specify my config file path every time, that won't work.
Is there something I can add to my phpunit.xml file to tell it to run tests using the /public directory as the "cwd" (current working directory)?
Based on the feedback I received in the comments and the documentation, I determined the following:
It's probably not possible to change the cwd that phpunit uses by default (well, it's possible in PhpStorm, but not the command line without writing some kind of wrapper script)
Code that depends on being run from a specific directory is not a good idea.
What I had was some code in one of my classes like this:
$var = file_get_contents("../some_file.json");
This works fine -- until you try to add unit tests. The web server runs using the /public directory as the cwd, while phpunit will run using the root directory.
Rather than trying to force phpunit to always use a particular cwd (/public), I decided it's probably best to remove relative paths from the code that rely on a consistent cwd. So the line above becomes:
$var = file_get_contents(base_path("some_file.json"));
I didn't want to change production code that was already working just to get some tests in place, but this change seemed insignificant enough. (and it's an improvement anyway)
Well, you'd have to do the actual chdir in PHP, but you can define a bootstrap script in the XML (<phpunit bootstrap="./bootstrap.php">) and have that change the working directory.
Alternatively, you can put a setUpBeforeClass function into your test class that changes the working directory.
I've installed the symfony plugin to PHPstorm, but when I'm trying to run the project I get the following error
Fatal error: Class 'Doctrine\Tests\Common\Cache\CacheTest' not found in ...
I've checked the path and CacheTest file is in the correct folder. When I run the symfony project from the command line it works just fine.
Is there someway to fix this problem?
What you try is not correct. You execute the php.exe and that is the normal PHP executable. To run your Unit-Tests you need PHPUnit to run.
Go to Preferences -> Languages & Frameworks -> PHP -> PHPUnit and define the phpunit.phar.
When you've done that you create a new configuration to run PHPUnit and you define the configuration which is under app/phpunit.xml.
I figured it out. First of all you need add phpunit.phar as Stony explained in his answer.
After that all I really needed to do was to rename phpunit.xml.dist to phpunit.xml in app/ folder and then just right click it and choose the Run 'phpunit.xml' option. This way the Tests succeed and it doesn't give any errors.
As for running the symfony project you need to add symfony command line tool support to phpstorm. All about that in this link: https://confluence.jetbrains.com/display/PhpStorm/Symfony2+Command+Line+Tool+Integration+-+Symfony+Development+using+PhpStorm
After that you just run it as a command like you would with normal command line. That's also explained in the link.
Try to choose "Use custom autoloader" option in Preferences -> Languages & Frameworks -> PHP -> PHPUnit and specify the path to vendor/autoload.php file.
I used the following command to generate the catalogs of my different Bundles and it worked well.
php app/console translation:update --dump-messages --force fr ProjectBlogBundle
But how should I do to translate the view that we can find on /app/Resources/views/* ?
Thanks,
If you check the command code, it looks like it's not possible: the bundle name is required and must be provided.
However, you can check this out.
Even though you can't automatically extract/update translation segments from those views, the runtime translation should work, provided that you use the same translation domain.
Even though this question is rather dated, I figured I might add this just for anybody else stumbling across this:
It seems that the desired functionality has been added in the meantime (Symfony 2.8+).
If you run the command like this:
$ app/console translation:update --help
Usage:
translation:update [options] [--] <locale> [<bundle>]
Arguments:
locale The locale
bundle The bundle name or directory where to load the messages, defaults to app/Resources folder
It seems the bundle name has become optionale and the command will default to app/Resources
I had the same problem, and the #Jan's answer helped me. So there is an example.
cd app/
php ./console console translation:update --dump-messages --force fr .
As . is a directory (the current directory), the translator will try to load the subdirectory /Resources, so here it will try to load app/Resources/.
I am trying to set some tests in symfony.
I am doing the first steps on that.
My question is from which folder should we write the phpunit -c app
I mean in c:/
or from the bundle
because I get the message of the not recognised internally command.
You must run it from root direcory of your application. app is just an argument which specify folder where phpunit.xml.dist places.