[master] entrypoint like /api/index.jsonld return an HTTP 404 with PHP built-in server · Issue #502 · api-platform/api-platform · GitHub
Skip to content

[master] entrypoint like /api/index.jsonld return an HTTP 404 with PHP built-in server #502

Closed

Description

@Rebolon

I'm trying to install the admin react but i have a problem with the uri of the entrypoint :

Where can i setup the entrypoint ? what's wrong with my configuration ?

System : Symfony4 with Flex, ApiPlatform on master branch
api_platform.yaml :

api_platform:
    title: 'My comics library'
    description: 'Demo of an API built with Api-Platform v2 (use REST or GraphQL). My comics library allow to manage your comics collection in a simple way'
    version: '1.0.0'
    mapping:
        paths: ['%kernel.project_dir%/src/Entity']
    formats:
        jsonld:  ['application/ld+json']
        json:    ['application/json']
        html:    ['text/html']
    graphql:
        graphiql:
            enabled: true

And annotations in entities.

Available project here https://github.com/Rebolon/php-sf-flex-webpack-encore-vuejs/tree/feature/graphql

Activity

  1. dunglas commented on Dec 28, 2017

    @dunglas
    Member

    Can you paste the output of bin/console debug:router? Does clearing the cache (rm -Rf var/cache) help?

  2. Rebolon commented on Dec 28, 2017

    @Rebolon
    Author

    Clearing the cache doesn't solve the problem.

    Here is the debug:router output

    -------------------------------------------- -------- -------- ------ --------------------------------------------
      Name                                         Method   Scheme   Host   Path                                       
     -------------------------------------------- -------- -------- ------ --------------------------------------------
      app_apiplatformreactadmin_index              GET      ANY      ANY    /demo/api-platform-admin
      token                                        ANY      ANY      ANY    /token
      token_check                                  ANY      ANY      ANY    /token_check
      app_default_index                            ANY      ANY      ANY    /
      app_form_index                               GET      ANY      ANY    /demo/form
      app_hello_world                              GET      ANY      ANY    /demo/hello/{name}
      app_httpplug_call                            GET      ANY      ANY    /demo/http-plug
      demo_secured_page                            GET      ANY      ANY    /demo/login/secured
      demo_login_standard                          ANY      ANY      ANY    /demo/login/standard
      demo_login_json                              ANY      ANY      ANY    /demo/login/json
      app_quasar_index                             GET      ANY      ANY    /demo/quasar
      app_vuejs_index                              GET      ANY      ANY    /demo/vuejs
      api_entrypoint                               ANY      ANY      ANY    /api/{index}.{_format}
      api_doc                                      ANY      ANY      ANY    /api/docs.{_format}
      api_graphql_entrypoint                       ANY      ANY      ANY    /api/graphql
      api_jsonld_context                           ANY      ANY      ANY    /api/contexts/{shortName}.{_format}
      api_authors_get_collection                   GET      ANY      ANY    /api/authors.{_format}
      api_authors_post_collection                  POST     ANY      ANY    /api/authors.{_format}
      api_authors_get_item                         GET      ANY      ANY    /api/authors/{id}.{_format}
      api_authors_delete_item                      DELETE   ANY      ANY    /api/authors/{id}.{_format}
      api_authors_put_item                         PUT      ANY      ANY    /api/authors/{id}.{_format}
      api_books_get_collection                     GET      ANY      ANY    /api/books.{_format}
      api_books_post_collection                    POST     ANY      ANY    /api/books.{_format}
      api_books_get_item                           GET      ANY      ANY    /api/books/{id}.{_format}
      api_books_delete_item                        DELETE   ANY      ANY    /api/books/{id}.{_format}
      api_books_put_item                           PUT      ANY      ANY    /api/books/{id}.{_format}
      api_books_reviews_get_subresource            GET      ANY      ANY    /api/books/{id}/reviews.{_format}
      api_editors_get_collection                   GET      ANY      ANY    /api/editors.{_format}
      api_editors_post_collection                  POST     ANY      ANY    /api/editors.{_format}
      api_editors_get_item                         GET      ANY      ANY    /api/editors/{id}.{_format}
      api_editors_delete_item                      DELETE   ANY      ANY    /api/editors/{id}.{_format}
      api_editors_put_item                         PUT      ANY      ANY    /api/editors/{id}.{_format}
      api_jobs_get_collection                      GET      ANY      ANY    /api/jobs.{_format}
      api_jobs_post_collection                     POST     ANY      ANY    /api/jobs.{_format}
      api_jobs_get_item                            GET      ANY      ANY    /api/jobs/{id}.{_format}
      api_jobs_delete_item                         DELETE   ANY      ANY    /api/jobs/{id}.{_format}
      api_jobs_put_item                            PUT      ANY      ANY    /api/jobs/{id}.{_format}
      api_project_book_creations_get_collection    GET      ANY      ANY    /api/project_book_creations.{_format}
      api_project_book_creations_post_collection   POST     ANY      ANY    /api/project_book_creations.{_format}
      api_project_book_creations_get_item          GET      ANY      ANY    /api/project_book_creations/{id}.{_format}
      api_project_book_creations_delete_item       DELETE   ANY      ANY    /api/project_book_creations/{id}.{_format}
      api_project_book_creations_put_item          PUT      ANY      ANY    /api/project_book_creations/{id}.{_format}
      api_project_book_editions_get_collection     GET      ANY      ANY    /api/project_book_editions.{_format}
      api_project_book_editions_post_collection    POST     ANY      ANY    /api/project_book_editions.{_format}
      api_project_book_editions_get_item           GET      ANY      ANY    /api/project_book_editions/{id}.{_format}
      api_project_book_editions_delete_item        DELETE   ANY      ANY    /api/project_book_editions/{id}.{_format}
      api_project_book_editions_put_item           PUT      ANY      ANY    /api/project_book_editions/{id}.{_format}
      api_reviews_get_collection                   GET      ANY      ANY    /api/reviews.{_format}
      api_reviews_post_collection                  POST     ANY      ANY    /api/reviews.{_format}
      api_reviews_get_item                         GET      ANY      ANY    /api/reviews/{id}.{_format}
      api_reviews_delete_item                      DELETE   ANY      ANY    /api/reviews/{id}.{_format}
      api_reviews_put_item                         PUT      ANY      ANY    /api/reviews/{id}.{_format}
      api_reviews_book_get_subresource             GET      ANY      ANY    /api/reviews/{id}/book.{_format}
      api_series_get_collection                    GET      ANY      ANY    /api/series.{_format}
      api_series_post_collection                   POST     ANY      ANY    /api/series.{_format}
      api_series_get_item                          GET      ANY      ANY    /api/series/{id}.{_format}
      api_series_delete_item                       DELETE   ANY      ANY    /api/series/{id}.{_format}
      api_series_put_item                          PUT      ANY      ANY    /api/series/{id}.{_format}
      api_series_books_get_subresource             GET      ANY      ANY    /api/series/{id}/books.{_format}
      easyadmin                                    ANY      ANY      ANY    /admin/
      admin                                        ANY      ANY      ANY    /admin/
      _twig_error_test                             ANY      ANY      ANY    /_error/{code}.{_format}
      _wdt                                         ANY      ANY      ANY    /_wdt/{token}
      _profiler_home                               ANY      ANY      ANY    /_profiler/
      _profiler_search                             ANY      ANY      ANY    /_profiler/search
      _profiler_search_bar                         ANY      ANY      ANY    /_profiler/search_bar
      _profiler_phpinfo                            ANY      ANY      ANY    /_profiler/phpinfo
      _profiler_search_results                     ANY      ANY      ANY    /_profiler/{token}/search/results
      _profiler_open_file                          ANY      ANY      ANY    /_profiler/open
      _profiler                                    ANY      ANY      ANY    /_profiler/{token}
      _profiler_router                             ANY      ANY      ANY    /_profiler/{token}/router
      _profiler_exception                          ANY      ANY      ANY    /_profiler/{token}/exception
      _profiler_exception_css                      ANY      ANY      ANY    /_profiler/{token}/exception.css
      index                                        ANY      ANY      ANY    /
      simple                                       GET      ANY      ANY    /demo/simple
      demo_login_standard_check                    ANY      ANY      ANY    /demo/login/authenticate
      logout                                       ANY      ANY      ANY    /logout
     -------------------------------------------- -------- -------- ------ --------------------------------------------
    
  3. Rebolon commented on Jan 3, 2018

    @Rebolon
    Author

    I tried with the latest version of api-platform/core: master and it still fail

  4. Rebolon commented on Jan 8, 2018

    @Rebolon
    Author

    @dunglas any option to solve that problem ? it seems that this feature works well with 2.1.4 (i downloaded this release, put my entities inside, and removed ApiSubResource annotation and it Works) but it fails on master

  5. Rebolon commented on Jan 9, 2018

    @Rebolon
    Author

    So : the problemd doesn't rely on master, but maybe in the way i installed ApiPlatform.

    • if i download the official distribution (release 2.1.4), and update the api-platfom/core to dev-master with composer, then everything works well
    • if i use Symfony4 with flex and add api from recipes it seems to not be enough. Here is the full require done with composer on my projet : composer req encore annotations twig api http profiler log doctrine-migrations admin

    Here are the steps to reproduce the problem with flex and api:

    Create a symfony project with flex (and cd into for all other commands):

    composer create-project symfony/skeleton api-platform-missing-index-hydra
    

    Edit your composer.json and add this (it reproduce the recipes api but with api-platform/core on master branch) :

        ,
        "minimum-stability": "dev",
        "prefer-stable": true,
        "repositories": [
            {
                "type": "vcs",
                "url":  "git@github.com:Rebolon/api-pack.git"
            }
        ]
    

    Then run those command to add required packages (for api and graphql):

    composer req annotations profiler log rebolon/api-pack 
    

    Add an entity in your src/Entity:

    <?php
    namespace App\Entity\Library;
    
    use ApiPlatform\Core\Annotation\ApiProperty;
    use ApiPlatform\Core\Annotation\ApiResource;
    use Doctrine\ORM\Mapping as ORM;
    
    /**
     * @ApiResource(
     *     iri="http://schema.org/Role"
     * )
     * @ORM\Entity
     */
    class Job
    {
        /**
         * @ORM\Id
         * @ORM\Column(type="integer")
         * @ORM\GeneratedValue(strategy="AUTO")
         */
        private $id;
    
        /**
         * @ApiProperty(
         *     iri="http://schema.org/name"
         * )
         * @ORM\Column(type="string", length=256, nullable=false)
         */
        private $tanslation_key;
    
        /**
         * id can be null until flush is done
         * @return int
         */
        public function getId(): ?int
        {
            return $this->id;
        }
    
        /**
         * @return string
         */
        public function getTanslationKey(): string
        {
            return $this->tanslation_key;
        }
    
        /**
         * @param mixed $tanslation_key
         * @return Job
         */
        public function setTanslationKey($tanslation_key): Job
        {
            $this->tanslation_key = $tanslation_key;
    
            return $this;
        }
    }
    

    Run a server:

    php -S localhost:8001 -t public
    

    With your browser go on localhost:8002/api: You should see the swagger UI with the Job entity
    Then click on the link jsonld at the bottom right of the screen: You will have a 404 Not Found

    So i expect something wrong with the way i install the api-platform. Am i missing something in the dependancies ?

  6. changed the title [-]How to configure the entrypoint ? /api/index.json leads to a 404[/-] [+][master] entrypoint like /api/index.jsonld return an HTTP 404[/+] on Jan 9, 2018
  7. o-rel commented on Jan 13, 2018

    @o-rel

    @Rebolon Have you find a fix ? I'm running on the same situation and even api_doc routes produce 404, which is annoying/blocking for testing with the admin app. Have you the same issue on those routes by the way ?

    Thanks.

    Edit : I was using php built-in server, since I've set up a nginx server and everything seems working.

  8. Rebolon commented on Jan 15, 2018

    @Rebolon
    Author

    It's not fixed on my side.

    I also run a php built-in server : i will try nginx to check if it solves this problem

  9. Rebolon commented on Jan 15, 2018

    @Rebolon
    Author

    thanks @o-rel in fact it works with nginx, but not with php built-in server
    @dunglas what features is mandatory on the server http that prevent the app to run on a php built-in server ?

  10. changed the title [-][master] entrypoint like /api/index.jsonld return an HTTP 404[/-] [+][master] entrypoint like /api/index.jsonld return an HTTP 404 with PHP built-in server[/+] on Jan 15, 2018
  11. bierdok commented on Mar 26, 2018

    @bierdok

    Add those lines like Silex documentation suggests

    public/index.php

    <?php
    
    $filename = __DIR__.preg_replace('#(\?.*)$#', '', $_SERVER['REQUEST_URI']);
    if (php_sapi_name() === 'cli-server' && is_file($filename)) {
        return false;
    }
    
    ...
    

    Run the built-in server:
    $ php -S localhost:8000 -t public index.php

    Voila!

  12. dunglas commented on Mar 26, 2018

    @dunglas
    Member

    We probably need to patch Symfony's index.php directly.

  13. bierdok commented on Mar 28, 2018

    @bierdok

    Another solution more simple would be to use Symfony's one: https://symfony.com/doc/master/setup/built_in_web_server.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions