Comments (16)
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.
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.
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.
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.
To make things short: The answer of the Laravel maintainer was "placing applications in subdirectories is not supported" ...
from aimeos-laravel.
Damn. Thanks for chasing this up.
from aimeos-laravel.
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.
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.
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.
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.
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.
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.
Oh fun. Hand-patching will get very old, very quick.
from aimeos-laravel.
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.
Thanks again for your help - this is simply something I'll have to work around
from aimeos-laravel.
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)
- Some functions report an error HOT 3
- API with laravel sanctum HOT 1
- laminas/laminas-diactoros problem with Laravel 10 and PHP 8.1+ HOT 1
- Running Custom Cronjob in Aimeos Laravel. HOT 1
- rest api for client aplication HOT 3
- error while running aimeos:setup HOT 1
- Please disregard
- 404 on catalog-filter.js and catalog-filter.css HOT 6
- Showing Class "\Aimeos\MShop\User\Manager\Standard" not found HOT 1
- Can't access to admin panel on fresh install
- Pricing rules issue, getting reset after placing order HOT 1
- How these actions are defined ? HOT 1
- Correction to installation instructions needed when installing Laravel Breeze HOT 1
- Integrating Urway-Payment into Aimeos Laravel Package HOT 2
- SQL syntax Error when running setup command. HOT 2
- [Solved] Dependency issue when installing aimeos... psr/http-message HOT 1
- The extension jqadm's index.blade.php is not taken into consideration HOT 1
- Changing shop prefix A non-recoverable error occurred in header (categories menu and search) HOT 8
- Auth API HOT 3
- New release supporting Laravel 11 HOT 2
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 aimeos-laravel.