Git Product home page Git Product logo

Comments (19)

scandel avatar scandel commented on May 30, 2024 7

@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.

chalasr avatar chalasr commented on May 30, 2024 4

@darius-v composer req annotations

from flex.

weaverryan avatar weaverryan commented on May 30, 2024 2

I created a pr to the docs to add the install line.

from flex.

AxelBriche avatar AxelBriche commented on May 30, 2024 1

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.

fabpot avatar fabpot commented on May 30, 2024

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.

fabpot avatar fabpot commented on May 30, 2024

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.

fabpot avatar fabpot commented on May 30, 2024

see symfony/symfony#22383

from flex.

stof avatar stof commented on May 30, 2024

@fabpot once Symfony 3.3 is stable, we won't need to set min-stability to dev though

from flex.

fabpot avatar fabpot commented on May 30, 2024

Yes, of course, I was referring to people who will test Flex in the next few weeks.

from flex.

fabpot avatar fabpot commented on May 30, 2024

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.

stof avatar stof commented on May 30, 2024

@fabpot we may want to create an annotations-pack requiring both doctrine/annotations and doctrine/cache though

from flex.

fabpot avatar fabpot commented on May 30, 2024

@stof Done in symfony/recipes#99

from flex.

darius-v avatar darius-v commented on May 30, 2024

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.

darius-v avatar darius-v commented on May 30, 2024

@chalasr - so this maybe should be in documentation? At least I cannot see: https://symfony.com/doc/current/routing.html#creating-routes

from flex.

jkobus avatar jkobus commented on May 30, 2024

Couldn't get 3.4 to work with annotations as I had the same problem. Thanks @chalasr.

from flex.

scandel avatar scandel commented on May 30, 2024

Exactly the same issue than @AxelBriche here.

from flex.

slootjes avatar slootjes commented on May 30, 2024

@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.

vincauddu29 avatar vincauddu29 commented on May 30, 2024

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.

achraf-jeday avatar achraf-jeday commented on May 30, 2024

Folder names are capitalized make sure not to misspell them like I did in the routes and annotations definitions.

from flex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.