Symfony2 bundle creating error - php

I am using windows system. I have just installed the symfony to my localhost as it is install with no error inside.
bellow url run fine with browser.
http://localhost/symfony/web/app_dev.php
now i have tried to create bundle from command prompt with following syntax.
php app/console generate:bundle --namespace=Acme/HelloBundle --format=yml
it shows an error like. "could not open input file."
however the environment variable is already set for command prompt.
so can any one please help me create bundle or give another way to create bundle in symfony.
Thanks.

What environment variable is set? Best thing is to run this command while you are in main project folder (in your case symfony folder).

Could not open input file.
implifies that app/console, does not exist. Make sure to run
cd path/to/your/symfony/folder
before trying to generate the bundle. :)

Run your command from your symfony root folder. Also try to do:
php app/console generate:bundle
it will ask you to specify a folder and format. Also that it needs to generate the structure.
Also check that your php-cli.ini has all the necessary configurations to execute the code.

Related

Symfony command php bin/console can't read Apache SetEnv?

With Symfony 5.2, when I execute this command
APP_ENV=prod php bin/console d:m:m
I have this message :
WARNING! You are about to execute a migration in database "db_name" that could ...
However, in my Apache environment variables, I customized the database name :
SetEnv DATABASE_URL "mysql://website:password#localhost:3306/website_prod"
I am sure that this configuration works (when I access the site, I am in the prod environment while I left dev in the .env generated by Symfony).
Why is the wrong database displayed on the APP_ENV=prod php bin/console d:m:m command line? I think Apache variables are not taken into account in php bin / console ... command line and I need to create a specific .env.prod.local.
Can you confirme ? If yes, I don't see why Symfony mentions this in their documentation (https://symfony.com/doc/current/setup/web_server_configuration.html#apache-with-mod-php-php-cgi)
Console commands do not run under the web-server, hence they do not have access to whatever configuration you have for the Apache vhost or anything like that.
The best way to deal with this kind of configuration is storing this values in environment variable, .env files, or use Symfony's secret management features.
This way this configuration will be available both to the application when accessed via the webserver or through a command line script.

PHP and composer command don't work without admin CMD

I have problem with my PHP and composer. I have set environment variables:
But whenever I call php or composer I get an error:
It's weird, because when I start cmd as an admin it works. But I want it to work always, because its much easier to write cmd to navigation path which opens the command line in exact path I use and don't need to write cd commands every time I need something.
Have you tried installing composer with the Windows GUI? If I remember correctly, it sets up your path variables itself.
https://getcomposer.org/doc/00-intro.md#installation-windows
You could try adding the same path to your user path variables too, in the first box. I guess you're restarting your CMD window?

Can't get PHPUnit working in PHPstorm

I am new to phpunit and I am trying to get it working with PHP storm. I have added composer and I have added the phpunit dependency and the files are all there. But when I try call phpunit in the command line I get this error.
I can't figure this out because I have tried calling phpunit and I have tried going through the folders to the files phpunit and phpunit.bat. Here is a picture of the folders and files.
It displays an error since your php is not being recognized. In order to fix the problem, you need to add your php directory to your PATH Environment Variable.
Screenshot of My System Variable
To verify that your php is now being recognized by the system, run the command php --version in your command prompt. It should display the version of your PHP

"cake bake" returns "env: node: No such file or directory"

I'm experienced with Ruby but new to PHP, getting CakePHP set up on my machine and I would love some help.
I've downloaded a version of Cake and placed it at /Users/zack/Sites/cake
From that directory, I've done cd cake/console and tried running cake bake but get the error env: node: No such file or directory
I've tried running chmod 755 cake to change permissions but that didn't work.
Any suggestions on how to get this working properly?
This is a pretty strange issue :))
1) You've installed coffeescript and it comes with a cake command. It's in /usr/bin so if there's no local cake available then it will run;
2) CakePHP's cake command only works if you are in an app folder (so cd myCakeApp first);
3) coffeescript's cake is a NodeJS script. It tries running node something. The error you are getting is telling you it could not find NodeJS.
Try prepending ./, so ./cake bake. That will make sure it only tries to run the cake command inside the current path/folder.

How to tell Git I'm upgrading php?

I've just upgraded PHP to the latest version. When I get back to Git, to my command shell, if I execute any PHP function, then I get this error :
sh.exe": php: command not found
I know I have to tell git bash where my new PHP path is, but I don't know how to do so and I can't find anything on Google about that.
EDIT :
I made a confusion you're right : I meant Git BASH by git. Thanks :)
SO here is the function I tried to call when I was dealing with symfony in the root foler of my app :
php app/console dump-sql
then Git BASH sent me the error above.
If you are windows, then following up on halfer's comment, it is required that you add the new
/bin/ directory of the php folder to your PATH.
To do this:
1. Open start menu
2. Right click my computer->properties
3. Click advanced tab -> Environment variables
4. Scroll down in the second listbox for a entry called PATH
5. add this to the end ;C:/%PHP_LOCATION%/bin
where %PHP_LOCATION% is the place that you installed PHP to.
I think you have git and bash confused.
Git is a program that would be running under bash, and isn't directly related to git unless you've gone out of your way to entangle them.
Most likely, the incantation you need is
export PATH=/path/where/php/is:$PATH
And then everything will be working. Note that needs to be the path to the directory, not the binary.
the $PATH at the end is to make sure that you don't clobber your old path.
I had the same error. I found that I needed the environment variable path in this format:
/c/wamp/bin/php/php5.3.13 (instead of C:\wamp\bin\php\php5.3.13)
Using Windows 7 & Git 1.7.10.

Categories