Giter Club home page Giter Club logo

Comments (16)

CyberiaResurrection avatar CyberiaResurrection commented on May 10, 2024 1

When I changed
return $this->_builder->route( $target, $params + $this->_fixed, $values['absoluteUri'] );
to
return $this->_builder->route( $target, $params + $this->_fixed, true );
in line 56 of the view helper, the route not found problem that I've been having goes away.

from aimeos-laravel.

aimeos avatar aimeos commented on May 10, 2024

If I've understood you correctly, your document root is your application base directory instead of its ./public subdirectory, so your URLs are like http://localhost/myapp/public/index.php/shop/list.

In this case, your problem isn't related to Aimeos because it uses the Laravel URL generator to create all URLs. Laravel expects the document root to be the ./public directory of your application by default due to security reasons (remember your .env file with your passwords is then publicly readable without further actions).

There seems to be a way to force Laravel to use another root directory:
http://stackoverflow.com/questions/25750604/laravel-artisan-gives-wrong-base-url
The question is related to the artisan CLI interface and Laravel 4.2 but the method is available in 5.x too and should also work in the HTTP environment.

from aimeos-laravel.

CyberiaResurrection avatar CyberiaResurrection commented on May 10, 2024

Thanks heaps for your help so far despite how thick I've been.

I haven't set any vhosts or anything, as I'm still developing.
The base is http://localhost/myapp/public - all the urls hang off that.

The only thing that is having problems is aimeos. Everything else in my laravel project picks up its target route (eg auth/register) and bolts that onto the end of the base url (http://localhost/myapp/public/auth/register)

I would expect shop/list to be http://localhost/myapp/public/shop/list , which I can browse to without a problem. It's just clicking Go from that view tries to go to http://localhost/shop/list , no matter what I set as the base url in config/app.php

from aimeos-laravel.

aimeos avatar aimeos commented on May 10, 2024

I would expect that too but I've found out that the Laravel URL generator behaves differently depending on what method you are using (to() vs. route()). I've created an issue for Laravel: laravel/framework#9829

from aimeos-laravel.

aimeos avatar aimeos commented on May 10, 2024

To make things short: The answer of the Laravel maintainer was "placing applications in subdirectories is not supported" ...

from aimeos-laravel.

CyberiaResurrection avatar CyberiaResurrection commented on May 10, 2024

Damn. Thanks for chasing this up.

from aimeos-laravel.

CyberiaResurrection avatar CyberiaResurrection commented on May 10, 2024

I'm not so sure it's a Laravel framework issue, now.

I stuck a dd(route('aimeos_shop_list')) call in my home controller's index method, and it returned http://localhost/myapp/public/shop/list as both you and I are expecting.

Doing a dd($adminUrl) call in Aimeos\Shop\Controller\AdminController.php immediately after line 61 gave '"http://localhost/myapp/public/admin/shop/admin?site=%7Bsite%7D&lang=%7Blang%7D&tab=%7Btab%7D"'

Third time (hopefully) being half a charm, I tried a dd($params) call in Aimeos\Shop\Controller\CatalogController.php just after line 60 (in listAction(), just after the app( 'Aimeos\Shop\Base\Page' )->getSections( 'catalog-list' ) and probably too much to just copy and paste here.

Highlights
aiheader['catalog/filter'] had a src of /shop/count
aiheader['catalog/list'] had a href of /shop/list - what I've tripped over previously.

That should be enough to establish the general pattern that, in that outpout from getSections, every single target url was of form /(foo), hanging directly off webserver root.

from aimeos-laravel.

aimeos avatar aimeos commented on May 10, 2024

Yes, it seems to work if an absolute URL should be generated (the route() helper does this by default). In all relative URLs the sub-directories are still missing.

from aimeos-laravel.

CyberiaResurrection avatar CyberiaResurrection commented on May 10, 2024

I'm not actually sure if the issue is in aimeos-laravel, or aimeos-core. Unless I'm even more wrong than usual, aimeos-core is where the getBody() implementations that return the non-subdir-sensitive links all seem to reside.

Would a Laravel-compatible test case expressing what I'm looking for be of any help?

from aimeos-laravel.

aimeos avatar aimeos commented on May 10, 2024

If the following returns a correct URL in your application, we should have a deeper look into it:
dd(route('aimeos_shop_list', [], false))

If the URL is wrong than Laravel has a bug creating relative URLs from routes.

FYI: All URLs generated in the Aimeos core are created by the Laravel view helper: https://github.com/aimeos/ai-laravel/blob/master/lib/custom/src/MW/View/Helper/Url/Laravel5.php

from aimeos-laravel.

CyberiaResurrection avatar CyberiaResurrection commented on May 10, 2024

Put that dd call in my home controller's index method, and it came back with
"/shop/list"

Which is not a correct URL for my setup. I'll have a look at the view helper.

from aimeos-laravel.

aimeos avatar aimeos commented on May 10, 2024

Yes, that's what I meant: Laravel builds absolute URLs correctly but generated relative URLs are wrong for your setup. The root problem is in this method: https://github.com/laravel/framework/blob/5.1/src/Illuminate/Routing/UrlGenerator.php#L289

from aimeos-laravel.

CyberiaResurrection avatar CyberiaResurrection commented on May 10, 2024

Oh fun. Hand-patching will get very old, very quick.

from aimeos-laravel.

aimeos avatar aimeos commented on May 10, 2024

The easiest way to get around this in your development environment is to use the integrated web server available since PHP 5.4. In your Laravel application directory type into a shell:
php -S 127.0.0.1:8000 -t public

Then, your Laravel application will be available at the URL http://127.0.0.1:8000/ and you won't have problems with URLs while developing :-)

from aimeos-laravel.

CyberiaResurrection avatar CyberiaResurrection commented on May 10, 2024

Thanks again for your help - this is simply something I'll have to work around

from aimeos-laravel.

aimeos avatar aimeos commented on May 10, 2024

You can try to fix it and open a pull request in the Laravel repository but it's not sure that it will be accepted.

from aimeos-laravel.

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.