Symfony 4 assets response error in dev , require which php extension? - php

In symfony I use bin/console server:run all resources response is invalid ~
example:
css response info by 'bin/console'
This is return a text and has not response header.
But when I use php -S 127.0.0.1:8000 -t public, it is worked!
css response info by 'php -S'
And there are some logs is samed in terminal They are all response 200!.
I think the reason is that I have some php extension not istalled.
So I composer require req-checker,But there is not required symfony required check
So who can tell me I will require which extension can fixed it.
Thanks!

Related

Symfony4 Route not found with path param if contains a dot

If I navigate to this route with this slug (/client/example.com)
/**
* #Route("/client/{url}")
*/
I get this error
The requested resource "/client/example.com" was not found on this
server.
I'm using php built-in server php -S 127.0.0.1:8000 public/index.php
With this aproach it works but assets doesn't load properly
php -S localhost:8000 public/index.php
Edit:
without dot it works.
php bin/console router:match /client/example.com
[OK] Route "client_show" matches
php bin/console router:match /client/example
[OK] Route "client_show" matches
As Lawrence Cherone stated in the comments looks like it doesn't work with the built-in php server but it does work with the composer require server included in Symfony Recipes.
php bin/console server:run

Selenium: FirefoxProfile exception Can't load the profile. Python script called from PHP

My python script has the following code:
firefox_profile = webdriver.FirefoxProfile()
self.driver = webdriver.Firefox(firefox_profile=firefox_profile)
When I execute the script from bash it works, but if I call the script from a PHP file, with the following command:
shell_exec("python path_to_the_script");
I receive the exception:
selenium.common.exceptions.WebDriverException: Message: Can't load the profile. Profile Dir: /tmp/tmp7Ob0z6/webdriver-py-profilecopy If you specified a log_file in the FirefoxBinary constructor, check it for details.
I've also tried to set the profile manually, like this:
firefox_profile = webdriver.FirefoxProfile(profile_directory='path_to_the_profile_dir')
But nothing changed, while if I set the profile directory path like this:
firefox_profile = webdriver.FirefoxProfile(profile_directory='path_to_the_profile_dir')
firefox_profile.profile_dir = 'path_to_the_profile_dir'
The exception error changes to this:
selenium.common.exceptions.WebDriverException: Message: Can't load the profile. Profile Dir: path_to_the_profile_dir If you specified a log_file in the FirefoxBinary constructor, check it for details.
I've set the permissions to 777 for all the involved directories, and also tried to override the FirefoxBinary.launch_browser function so that it uses a greater timeout value, but id did not work.
I'm using Python 2.7, Selenium 2.53.6 and Firefox 46.0.1
Firefox is working in headless mode, through Xvfb and pyvirtualdisplay.
This happens because you have updated firefox to a version that's no longer supported by selenium.
So to fix this you have 2 options.
Downgrade your firefox to an older version then 47
Update Selenium and Install geckodriver (recommended and easy)
If you have ubuntu follow this fix below:
1. Update selenium with "sudo pip install -U selenium"
2. Download the geckodriver from github -->
Gecko Github Link
3. Extract the tar.gz folder and move the gecko executable to /usr/local/bin
4. Now open your terminal and enter this command: export PATH=$PATH:/usr/local/bin/geckodriver
That should fix the issue... atleast it worked for me.
My Source: StackOverflow - Geckodriver
If that didn't fix your issue check your firefox profile name
like this
fp = webdriver.FirefoxProfile('/home/YOUR_USERNAME/.mozilla/firefox/YOUR_PROFILE_NAME.default')
driver = webdriver.Firefox(firefox_profile=fp)
To find your firefox profile name open your file browser and enable "show hidden files" go to "Home/.mozilla/firefox" and you'll see your firefox profile folder.
I hope that solved your issue

PHP built-in web server is not finding assets

I have a php project built with Zend Framework 2. In want to start the built-in server to developing with the following command:
sudo php -S localhost:8080 -t public/ public/index.php
All the functionality of Zend Frameowrk 2 are working fine but I get 404 errors when retrieving the assets.
The assets are in the public/css, public/img and public/js folder.
GET
http://localhost:8080/css/bootstrap.css [HTTP/1.1 404 Not Found 10ms]
GET
http://localhost:8080/css/dlu-tw-bootstrap.css [HTTP/1.1 404 Not Found 21ms]
GET
http://localhost:8080/css/style.css [HTTP/1.1 404 Not Found 35ms]
GET
http://localhost:8080/js/bootstrap.js [HTTP/1.1 404 Not Found 45ms]
Any idea on how to allow the built-in server to access these files?
As I understood from reading this blog post, you either need to start your command from the right folder and not specify any -t option
$ cd public
$ sudo php -S localhost:8080
Or you need to write your own routing rules in the index.php

How to load php_redis.dll when running post deployment script in Kudu Console

I have a webapp running on Azure App Service. I am trying to test a Post deployment script in Kudu Debug CMD console.
php -d extension=php_redis.dll -f postdeploy.php
Here is my postdeploy.php file
<?php
ini_set('error_reporting', -1);
ini_set("display_errors", 1);
function exception_handler($exception) {
echo "Uncaught exception: " , $exception->getMessage(), "\n";
}
set_exception_handler('exception_handler');
$redis = new Redis();
...
?>
I get the following error
Fatal error: Class 'Redis' not found in D:\home\site\deployments\tools\PostDeploymentActions\postdeploy.php on line 13
PHP Warning: PHP Startup: Unable to load dynamic library 'D:\Program Files (x86)\PHP\v5.6\ext\php_redis.dll' - The specified module could not be found.
in Unknown on line 0
I uploaded the proper version of php_redis.dll to the PostDeploymentActions folder. This is the same binary that the webapp is using via the app setting in portal PHP_EXTENSIONS = bin\php_redis.dll. However, I am not sure how to load this for this script.
Is there a way that I can load the php_redis.dll in Kudu post deployment script?
I tried php -d extension=./php_redis.dll -f postdeploy.php, php -d extension=%~dp0php_redis.dll -f postdeploy.php and other weird combinations with no luck.
Please try to add the PHP extension via ini settings, refer to https://azure.microsoft.com/en-us/documentation/articles/web-sites-php-configure/#how-to-enable-extensions-in-the-default-php-runtime at the Configure via ini settings section.
Generally:
Add an App Setting to your Web App with the key PHP_INI_SCAN_DIR and value d:\home\site\ini
Create an configuration file in d:\home\site\ini called extensions.ini
Add configuration settings to the extensions.ini file using the same
syntax you would use in a php.ini file. For example: extension =
php_redis.dll.
Restart Web Apps service.
Via this approach, you can configure the PHP extension into Kudu console site's PHP runtime. And configure via the App Settings will only configure the extension into IIS.
Any further concern, please feel free to let me know.

installing php symfony installer

I am using this cmd
php -r "file_put_contents('symfony', file_get_contents('https://symfony.com/installer'));"
output i am getting
Warning: file_get_contents(https://symfony.com/installer): failed to open stream
: No connection could be made because the target machine actively refused it.
in Command line code on line 1
i on proxy so that above cmd will not work directly .
I found some solution on stack overflow
Install Symfony on Windows behind proxy server with NTLM authentication
but its not working for me
I tried setting http_proxy and https_proxy env variable but it dint worked for me
Are there any chances of problem because of ssl ?
Can you access https://symfony.com/installer in your browser? If you can, it'll download a PHAR file for you. This file is ready to be used. You can put this in your "projects" directory and use it as:
> php symfony.phar new blog
Or you can move it to a location that's in your PATH and create a bat executable file:
#echo off
php "C:\path\to\symfony.phar" %*
Now you can use it like this:
> symfony new blog

Categories