Comments (19)
@AxelBriche, in my case I had forgotten the .htaccess
, which is not created by default with symfony/flex. Posted a complete answer here: https://stackoverflow.com/a/49209861/2761700
from flex.
@darius-v composer req annotations
from flex.
I created a pr to the docs to add the install line.
from flex.
Hello, I have this error:
The requested URL /message was not found on this server.
composer req annotations
annotations.yaml
controllers:
resource: ../../src/Controller/
type: annotation
routes.yaml
#index:
# path: /
# controller: App\Controller\MessageController::index
MessageController.php
<?php
namespace App\Controller;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class MessageController extends Controller
{
/**
* @Route("/message", name="message")
*/
public function index()
{
return $this->render('message/index.html.twig', [
'controller_name' => 'MessageController',
]);
}
}
php bin/console debug:router
show the route:
Name Method Scheme Host Path
message ANY ANY ANY /message
But the route /message doesn't work.
Another routing problem:
"An error occurred while loading the web debug toolbar"
"The requested URL /_profiler/4029fd was not found on this server."
Note: It's a clean new Flex installation, I have followed the official doc.
Note2: I have run: composer require sensio/framework-extra-bundle, already installed.
from flex.
The error message, while technically exact, is not the "right" one. By the ways, we have many of these issues now because we are using components individually. I've fixed some of them in 3.3, but I'm sure there are many other ones.
Here, the annotation loader is not registered as you probably don't have Doctrine annotations installed. Anyway, even when doing so, you also need SensioFrameworkExtraBundle to make it work.
Try composer req sensio/framework-extra-bundle annot
and this should fix the issue.
To "fix" this, we should probably move the routing annotation loader definitions from the extra bundle to the core framework (possible as all classes are in the routing component). We can auto-register these loaders when annotations are available.
This would still need the Doctrine annotations lib, but adding a comment in the default routing.yaml
would go a long way (which I will do now).
from flex.
There is another issue here: as we need to set minimum-dep
to dev
, it installs dev-master
for all packages. But framework extra bundle at master is WIP and does not work with the any other dep as it's a major version. That's the kind of things that I think we cannot really fix and why Flex is really just a preview before Symfony 4.0.
from flex.
from flex.
@fabpot once Symfony 3.3 is stable, we won't need to set min-stability to dev though
from flex.
Yes, of course, I was referring to people who will test Flex in the next few weeks.
from flex.
Closing as we improved the error message and because 3.4 will support annotations out of the box without the need to install framework-extra bundle. We also added a note in the routing file.
from flex.
@fabpot we may want to create an annotations-pack requiring both doctrine/annotations and doctrine/cache though
from flex.
@stof Done in symfony/recipes#99
from flex.
Should annotation routes work? I just installed symfony 4.
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route;
class PersonController extends Controller
{
/**
* Matches /blog exactly
*
* @Route("/", name="blog_list")
*/
public function list()
{
// ...
return 'b';
}
/**
* Matches /blog/*
*
* @Route("/blog/{slug}", name="blog_show")
*/
public function show($slug)
{
// $slug will equal the dynamic part of the URL
// e.g. at /blog/yay-routing, then $slug='yay-routing'
// ...
}
}
This does not work. I think I do ok by documentation. Composer.json :
{
"type": "project",
"license": "proprietary",
"require": {
"php": "^7.1.3",
"ext-iconv": "*",
"symfony/console": "^4.0",
"symfony/flex": "^1.0",
"symfony/framework-bundle": "^4.0",
"symfony/lts": "^4@dev",
"symfony/twig-bundle": "^4.0",
"symfony/yaml": "^4.0"
},
"require-dev": {
"symfony/dotenv": "^4.0"
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"symfony/polyfill-apcu": "*",
"symfony/polyfill-php70": "*",
"symfony/polyfill-php56": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"id": "01C1AMZG7RRHZQ87EJYRTRWDDA",
"allow-contrib": false
}
}
}
I get error:
No route found for "GET /"
from flex.
@chalasr - so this maybe should be in documentation? At least I cannot see: https://symfony.com/doc/current/routing.html#creating-routes
from flex.
Couldn't get 3.4 to work with annotations as I had the same problem. Thanks @chalasr.
from flex.
Exactly the same issue than @AxelBriche here.
from flex.
@scandel in that case you would see an Apache "404 Not Found", not a Symfony error page so I don't think that can be it in this case.
edit: in case of @AxelBriche it does look like an Apache error indeed :)
from flex.
I have a same problem.
{ "type": "project", "license": "proprietary", "require": { "php": "^7.0.8", "ext-ctype": "*", "ext-iconv": "*", "sensio/framework-extra-bundle": "^5.2", "symfony/console": "4.2.*", "symfony/dotenv": "4.2.*", "symfony/flex": "^1.1", "symfony/framework-bundle": "4.2.*", "symfony/yaml": "3.4.*" }, "config": { "preferred-install": { "*": "dist" }, "sort-packages": true }, "autoload": { "psr-4": { "App\\": "src/" } }, "autoload-dev": { "psr-4": { "App\\Tests\\": "tests/" } }, "replace": { "paragonie/random_compat": "2.*", "symfony/polyfill-ctype": "*", "symfony/polyfill-iconv": "*", "symfony/polyfill-php70": "*", "symfony/polyfill-php56": "*" }, "scripts": { "auto-scripts": { "cache:clear": "symfony-cmd", "assets:install %PUBLIC_DIR%": "symfony-cmd", "bin/docker-upgrade": "php-script" }, "post-install-cmd": [ "@auto-scripts" ], "post-update-cmd": [ "@auto-scripts" ] }, "conflict": { "symfony/symfony": "*" }, "extra": { "symfony": { "allow-contrib": "true", "require": "4.2.1" } }, "require-dev": { "ajardin/docker-symfony": "^0.4.0" } }
`<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
class testController extends AbstractController {
/*
* @Route("/api", name="index")
*/
public function index() {
return new JsonResponse("test");
}
}`
/var/www/html # bin/console debug:router -vvv
Name Method Scheme Host Path
I am under nginx server and i have used nginx config :
`server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name symfony.localhost;
root /var/www/html/public;
ssl on;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
location / {
# try to serve file directly, fallback to index.php
try_files $uri /index.php$is_args$args;
}
location ~ ^/index\.php(/|$) {
fastcgi_pass php:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
# When you are using symlinks to link the document root to the
# current version of your application, you should pass the real
# application path instead of the path to the symlink to PHP
# FPM.
# Otherwise, PHP's OPcache may not properly detect changes to
# your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
# for more information).
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
# Prevents URIs that include the front controller. This will 404:
# http://domain.tld/index.php/some-path
# Remove the internal directive to allow URIs like this
internal;
}
# return 404 for all other php files not matching the front controller
# this prevents access to other php files you don't want to be accessible.
location ~ \.php$ {
return 404;
}
}`
Can you help me ?
from flex.
Folder names are capitalized make sure not to misspell them like I did in the routes and annotations definitions.
from flex.
Related Issues (20)
- Renaming of docker-compose.yaml in compose.yaml : postgresql does'nt work anymore HOT 8
- Unclear problem description when Flex blocks package installation (by `extra.symfony.require` rule) HOT 1
- [Feature] Recipe endpoint for private recipe should not be in the project but in the bundle
- Missing tag for version v1.21.5 ? HOT 3
- Remove importmap entries when uninstalling a package
- ComposerScriptsConfigurator can break "composer.json" filename in patch
- Symfony Flex 1.8.5 is not compatible with Composer 2.7.0
- Symfony Flex fails when using Composer 2.7.0, running as root HOT 7
- Unable to update recipe HOT 5
- PackageJsonSynchronizer is not fail safe HOT 1
- Invalid version string "master.9999999" HOT 2
- Make packages.json synchronization optional
- recipe_template_relative processing is broken for gitlab private recipe
- Remove version tag in compose file as marked as obsolete by lastest docker compose version HOT 3
- Allow organize private recipes in subdirectories HOT 5
- Feature request: Update recipes non interactive
- Suggest adding management of the compose.yml file in addition to docker-compose.yml HOT 1
- Optimized key management to avoid duplication
- Support for local stored recipe files
- Resolving dependencies fails for symfony/psr-http-message-bridge after change of recipe
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flex.