I've installed symfony but now when i am trying to create a folder i see a error i have never seen before
symfony : The term 'symfony' 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
symfony new my_project_directory --version=5.4 --webapp
+ CategoryInfo : ObjectNotFound: (symfony:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
enter link description here
I have tried guideness on other stackoverflow answers and tried some youtube video's nothing helped me out.
From the video linked in your post, it seems like you're on Windows and your default Terminal is PowerShell. Symfony executable (or its installation) uses Bash, which isn't supported by windows, and the error is in the video:
The term 'bash' is not recognized ...
This error isn't related to PHP or Symfony, but to the underlying OS you're using. In my experience, programming in PHP on Windows itself is not convenient. I'd suggest to use Windows WSL2 so you don't run into these kinds of problems. I have experience with WSL2 as I'm using it myself, and I can nothing but recommend it.
Related
I am trying to create a simple symfony project.
I run this on console:
composer create-project symfony/skeleton myProjectName
php -S 127.0.0.1:8000 -t myProjectName/public
Project succesfully run at localhost:8000. However, when I begin to inspect the code, I realized VS Code editor is indicating "Undefined type" error in projectDirectory/src/Kernel.php file. Do you have any ideas why this happens and any suggestions towards solution?
I use PHP v7.4.32 and Symfony 5.4 for development. My helper extentions are PHP Intelephense v1.8.2 and PHP IntelliSense v1.0.11.
projectDirectory/src/Kernel.php
The Error
Since it runs succesfully on browser, I dubted that the classes exist somewhere but the VSCode could not solve the relative paths. Then, I tried a couple of extensions. Installation of PHP v1.22.11089 created by DEVSENSE and PHP Namespace Resolver v1.1.9 created by Mehedi Hassan has solved the problem.
I created a new project using Symfony 5.1.2, then I tried to run the server using
symfony serve. Once I tried to access localhost:8000, I had this warning in the terminal : [Web Server/PHP ] Jun 22 13:47:55 |WARN | SERVER GET (404) / ip="::1".
Moreover, the page I had was symfony's default page saying "#Page not found".
I checked the existing routes and I had default ANY ANY ANY /.
I also checked the DefaultController, but everything looks fine, since it is the auto generated controller...
I don't know what else to check, how could I get this default page working ?
I had a similar issue : I had run symfony server:start and was even seeing it react to my entering HTTP addresses in the browser, but I kept having that "# Page not found" message.
Quite simply, my symfony project was in Group/SubGroup/Project... and I was running symfony server:start from Group/SubGroup. When I stopped Symfony and ran it again from Group/SubGroup/Project, it worked like a charm.
A beginner's mistake, to be sure, but beginners use this site too.
Did you run the symfony project? It will show if you didn't run the symfony project. Run the project from terminal.
cd my-project/
symfony server:start
ip="::1" is the localhost on windows and wsl 2. Symfony server listen on 127.0.0.1:8000.
You must edit the windows hosts file at C:\Windows\System32\drivers\etc\hosts.
Add this line : 127.0.0.1:8000 localhost:8000
It works for me.
I'm completly new to Symfony and tried the following guide: https://github.com/thecodingmachine/symfony-vuejs ... but without docker (I have a simple webspace, I can't use docker there).
Now I'm stuck right in the beginning, when calling composer install in the app root. I get the following message:
In EnvVarProcessor.php line 131:
Environment variable not found: "DATABASE_URL".
Well, that sounds easy, I have to setup an enviroment variable ... but I'm not using docker and I don't want to set up a temporarly variable in the shell. Few seconds of google helped me, that I can use .env for my problem like descriped here: https://symfony.com/doc/current/configuration.html#configuration-based-on-environment-variables
In the example project is already a .env file, so I extendet it by DATABASE_URL. But suddenly it is not taking that variable.
I'm working on a macbook with a simple apache/php setup without forther configuration.
What am I missing?
Few weeks ago I set up a Message system with Symfony Messenger and it worked great.
Today I wanted to create new object through message, so I went to my server and type the command to consume message
First I had this result
$ bin/console messenger:consume-messages amqp_notifications
/usr/bin/env: ‘php\r’: No such file or directory
It never happened before with my files, and I never changed the line ending or encoding of my file sin PHPstorm.
I tried to use $ php bin/console messenger:consume-messages amqp_notifications
but then I had this error.
Attempted to load class "AMQPConnection" from the global namespace.
Did you forget a "use" statement?
Pretty weird, because I have have the php-amqp ext installed as you can see on the screenshot of my phpinfo
I didn't change anything in my Message class or Handler.
Also, I tried to call new AMQPConnection() on a random action, just to try, and I didn't get the error.
I'm completely lost with this error this time, as everything is installed.
I use PHP 7.3.1 and symfony Messenger 4.2.2
It seems your second issue was already solved by ccKep on his comment.
The first one is that the specific shebang line #!/usr/bin/env php executes the first php found in the $PATH. So if you already have uninstalled it, which seems the case, or it has a symbolic link to another php version, you can get a wrong result.
Tries to check what is inside the $PATH and replace the PHP path for the correct one. You might get the place running which php.
I'm new to symfony and I am trying to run a simple command on the command line but I get an error message.
When I try to execute the command:
d:\new_xam\xampp\htdocs\sf_sandbox_1_2\sf_sandbox>symfony propel:build-model "
I get the error:
'php.exe' is not recognized as an
internal or external command,operable
program or batch file.
Can anybody help me?
This is a fairly common issue on Windows systems for people new to Symfony and/or PHP. It seems to be an issue with the PHP path. See here: http://forum.symfony-project.org/index.php/m/44895/?srch=php.exe+command#msg_44895
Can you try to use the real path for PHP?
i.e.,
"C:\Program Files\PHP\PHP.exe" symfony propel:build-model
At your Symfony directory.
You should be able to prefix everything with "php".
So instead of symfony propel:build-model you can do php symfony propel:build-model.