Symfony4 Route not found with path param if contains a dot - php

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

Related

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

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!

How to find the path to setup Laravel Aimeos cron job?

I am unable to find the path to Artisan. I need to execute this:
php /path/to/artisan aimeos:jobs "admin/job order/email/delivery order/email/payment order/service/delivery"
My project path is: vagrant#vagrant-ubuntu-trusty-64:/var/www/html/shop$
I get the result:
No command 'app' found, but there are 17 similar ones
app: command not found
Full path: /Users/devika/Desktop/laraveltrusty/data/shop/artisan

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

CakePHP shell script won't run as cron job

I have written a shell script that works perfectly when I test it locally.
bin/cake myshell method
But when I assign it as a crob it's not working. Instead I see the default cake output:
Welcome to CakePHP v3.1.4 Console
---------------------------------------------------------------
App : src
Path: /home/fantastagram/public_html/src/
PHP : 5.6.16
---------------------------------------------------------------
Current Paths:
* app: src
* root: /home/fantastagram/public_html
* core: /home/fantastagram/public_html/vendor/cakephp/cakephp
Available Shells:
[Migrations] migrations
[CORE] i18n, orm_cache, plugin, routes, server
[app] console, instagram
To run an app or core command, type `cake shell_name [args]`
To run a plugin command, type `cake Plugin.shell_name [args]`
To get help on a specific command, type `cake shell_name --help`
Content-type: text/html; charset=UTF-8
It appears that the two arguments to the script are being ignored. I'm using the cron jobs tool in the cPanel...
What am I doing wrong?
I turned on debugging and found that the script was actually erroring out before it to my parameters. I googled the error and it turned out to be this: Cakephp 3 bin/cake bake - Undefined variable: argv
Tweaked the php.ini config and it worked perfectly.

symfony2 assets targets the /www server folder, not the /web symfony folder when deploy in production

I have some problems with Symfony 2 application deployment. I have import all files I need on my OVH shared server, but some errors occured like css and js files not found (internal server error for example) or error like Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://my-server/css/458dafd_bootstrap-theme.min_1.css".
Notice that I have installed the CoresphereBundle in order to have a console in my browser when my application is iploaded on my server, I have access to the console only on dev environment.
This is step by step what I did in order to deploy my application:
1 I updated my application and vendors with composer (because I have no ways to install composer on my server)
composer.phar update
2 I clear the dev cache php app/console cache:clear
3 I clear the prod cache php app/console cache:clear --env=prod --no-debug
4 I install assets php app/console assets:install web
5 I dump the assets php app/console assetic:dump web
6 I uploaded my symfony application on my server.
7 Once the files are uploaded in web/app.php I I authorize
the prod debug
$kernel = new AppKernel('prod', true);
8 Then in web/config.php I remove this block
// …
if (!in_array(#$_SERVER['REMOTE_ADDR'], array(
'127.0.0.1',
'::1',
))) {
header('HTTP/1.0 403 Forbidden');
exit('This script is only accessible from localhost.');
}
So, on my server, if I would like to go to http://my-server/web/config.php it works well, so I see if my server is compatible with symfony. the only thing that appears is Set short_open_tag to off in php.ini*.
9 I set the access rights for the app/cache and app/log folders to 777 on my server, it allows the applications to write in these folders.
10 In web/app_dev.php I write this code, in order to allow the dev mode for my IP adress and so have access to the console bundle
// …
if (!in_array(#$_SERVER['REMOTE_ADDR'], array(
'127.0.0.1',
'::1',
'121.457.719.2' //a random ip adress it's just for you to understand
))) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}
11 So I have access to the dev environment on my server, all works well, and no errors occured here. To access to the console bundle, following to the bundle documentation, I have to wrote http://my-server/web/app_dev.php/_console (see the routing code here):
_console:
resource: "#CoreSphereConsoleBundle/Resources/config/routing.yml"
prefix: /_console
But this routes does not exist, If I wrote this url, nothing appear in my browser:
However, by the config.php, I have access to app_dev.php by following the Bypass configuration and go to the Welcome page link:
I click on the link and I arrived on app_dev.php. Like I said before, no errors occured in this environment, except for the console route. But I could have access to the console by clicking on the console logo under the symfony debug toolbar:
This is the url for the console when I click on the logo under symfony debug toolbar: http://my-server/web/app_dev.php//_console/_console, I would like to understand why?
Then when I would like to make some commands another error occured: [error] Internal Server Error in the console:
If I try to use the router debug php app/console debug:router, I have this:
and with the php app/console debug:router | grep _console:
So, there are the problems I have with my symfony application.
UPDATE
I resolved the problem of the console bundle. In fact my server does not use the same php version of my symfony application, I have to set this in the .ovhconfig at the root of my /www folder.
/www/.ovhconfig:
app.engine=php
app.engine.version=5.5
http.firewall=none
environment=production
Now when I would like to access to the production environment I have these errors concerning all my assets files (css/js/images, a 404 not found):
Failed to load resource: the server responded with a status of 404 (Not Found) -> http://my-server.com/bundles/fosjsrouting/js/router.js
Uncaught ReferenceError: fos is not defined -> routing:1
Failed to load resource: the server responded with a status of 404 (Not Found)
->http://my-server.com/css/45898d_dataTables.min_7.css
I don't really understand, the files are indeed at the root of the app, e-g I have no folder css or js or etc in http://my-server.com/. These folders are in http://my-server.com/web/. Where is the problem?
When I access to the console, this is the command I made:
1 cache:clear
2 assets:install web
3 assetic:dump web
EDIT: solution works
I understand that the assets target a /css /js /images etc folder at the root of my server, so I replace the css and js files to the root of the /www server folder, e-g in the /www folder of my server I have this:
//my server
/.ssh
/www /*http://my-server.com/...*/
/app/
/bin/
/css/
/fonts/
/images/
/js/
/src/
/vendor/
/web/
/.htaccess
/.ovhconfig
/composer.json
/composer.lock
/composer.phar
Why my symfony application tagets the assets here?
Have you tried to use the Symfony command line routing debugger?
php app/console debug:router
That will output all the routes the symfony app knows about and you could try piping it into grep to see if you're trying to use the wrong path to hit the _console route.
php app/console debug:router | grep _console

Categories