Sylius / Sylius-Docs

DEPRACATED. See Sylius/Sylius repository.
http://sylius.org
56 stars 99 forks source link

Cannot load resource "alias: app.book #393

Open abhinavkumar940 opened 8 years ago

abhinavkumar940 commented 8 years ago

I am on Symfony v2.8.0

app/AppKernel.php

new FOS\RestBundle\FOSRestBundle(),
new JMS\SerializerBundle\JMSSerializerBundle($this),
new Sylius\Bundle\ResourceBundle\SyliusResourceBundle(),
new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
new Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle(),

app/config/config.yml

sylius_resource:
    resources:
        app.book:
            classes:
                model: AppBundle\Entity\Book

app/config/routing.yml

app_book:
    resource: |
        alias: app.book
    type: sylius.resource_api

And then when I do ./bin/console debug:router

I get

[Symfony\Component\Config\Exception\FileLoaderLoadException]  
Cannot load resource "alias: app.book                         
".       

Please note that the exception is a FileLoaderLoadException I'd assume that it hasn't even reached Sylus yet.

Would love to provide a PR if somebody gives me a direction.

michalmarcinkowski commented 8 years ago

You have to provide alias in the routing config.

app_book:
    resource: |
        alias: app.book
    type: sylius.resource
abhinavkumar940 commented 8 years ago

Thank you for your prompt response @michalmarcinkowski That must have lost during the copy/paste transition but I can confirm that I have alias in my code, and the error is still there

pjedrzejewski commented 8 years ago

@abhinavkumar940 Thanks for report, I will try to reproduce the problem and get back to you.

pjedrzejewski commented 8 years ago

Hello @abhinavkumar940, I just tried the docs with clean Symfony 2.8 and everything seems to work - https://github.com/pjedrzejewski/SRB-Example. Have a look if you have any differences. Anyway, I discovered another small issue with the documentation, so it's a plus. :) Let me know if you figure it out. I will leave this open until you give us feedback, thanks!

abhinavkumar940 commented 8 years ago

Hi @pjedrzejewski many thanks for your reply. Here are my findings.

Your test repo works, but it's using dev-master and not one of the tagged releases. I just created a blank 2.8 project which uses 0.15 it replicates the issue. https://github.com/abhinavkumar940/SRB-Example-Stable

michalmarcinkowski commented 8 years ago

@abhinavkumar940 the docs are up to date with current master. The 0.15 release doesn't have this configuration options. Add to your dependencies "sylius/resource-bundle": "0.16.*@dev" or wait for 0.16.0 version (should be released tomorrow).

abhinavkumar940 commented 8 years ago

That's still kind of an issue, right? I mean I am sure to encounter that even if I follow the docs.

Anyways, I've got to lower my minimum-stability setting in composer to get that working. If you find it's okay, I will close this.

Let me know, thanks.

gabiudrescu commented 8 years ago

somehow, I ended up here searching for the error @abhinavkumar940 had initially to figure out the planets would not align very well for those who use this bundle for the first time - especially on Ubuntu 14.04.

if you use symfony installer like this: symfony new test 2.8

the symfony instance will have the following composer.json:


    "config": {
        "bin-dir": "bin",
        "platform": {
            "php": "5.3.9"
        }
    },

and using composer require sylius/resource-bundle ^0.16 you'll get an error on Ubuntu 14.04 claiming 5.5.9-1ubuntu4.14 != 5.5.9 and there are missing dependencies from this bundle.

that's how I ended up using 0.15 and bumped into this error. maybe there should be a mention in the doc for using 0.16 or above as there are BC.

happy to do a small PR on that if I get the green light :)