contao / contao-manager

Contao Manager
GNU Lesser General Public License v3.0
86 stars 33 forks source link

No route found for "GET /contao-manager.phar.php/api/session" - CM unter Laravel Valet (nginx) #587

Closed pgerundt closed 4 years ago

pgerundt commented 4 years ago

Hallo Entwicklergemeinde! Hat irgendjemand den CM schon unter Laravel Valet (nginx) zum Laufen gebracht? Meine kläglichen Versuche bisher:

Versuch A: Neues Valet-Projektverzeichnis (contao) anlegen und contao-manager.phar dorthin kopieren, in .phar.php umbenennen. Ergebnis: Der BasicValetDriver wird verwendet; Aufruf von http://contao.test/contao-manager.phar.php wird von der Funktion rewrites() nach http://contao.test/contao-manager.phar.php/ weitergeleitet; Prüfung durch BasicValetDriver::isStaticFile() liefert false zurück; Valet gibt 404 zurück.

Versuch B: Neues Valet-Projektverzeichnis (contao) mit Unterverzeichnis web anlegen und contao-manager.phar dorthin kopieren, in .phar.php umbenennen. Ergebnis : siehe Versuch A

Versuch C: Neues Valet-Projektverzeichnis (contao) mit leeren Verzeichnissen /vendor/contao anlegen; Unterverzeichnis web mit leerer app.php anlegen und contao-manager.phar dorthin kopieren, in .phar.php umbenennen. Ergebnis: Der ContaoValetDriver wird verwendet; bei Aufruf von http://contao.test/contao-manager.phar.php wird (fälschlicherweise) die app.php ausgeführt.

Versuch D: wie Versuch C; mit zusätzlicher Anpassung (wird später mal ein Custom Valet Driver) von ContaoValetDriver::frontControllerPath():

if (0 === strncmp($uri, '/contao-manager.phar.php', 24)) {
    return $sitePath.'/web/contao-manager.phar.php';
}

Ergebnis: Der ContaoValetDriver wird verwendet; Aufruf von http://contao.test/contao-manager.phar.php wird weitergeleitet nach http://contao.test/contao-manager.phar.php/#/discover; Requests für Stylesheets (/css), JavaScript-Chunks (/js) und Bilder (/img) funktionieren, aber alle Requests auf die API (/api) kommen mit 404 zurück; Meldung ist ERROR 404 Unerwarteter API-Status. Fehlermeldung im Log: app.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /contao-manager.phar.php/api/session"

Suche im Forum, Internet und hier brachte leider keine Lösung.

fritzmg commented 4 years ago

Versuch A: Neues Valet-Projektverzeichnis (contao) anlegen und contao-manager.phar dorthin kopieren, in .phar.php umbenennen.

You need to create a web/ subdirectory in your target directory for the Contao installation. See the instruction on https://contao.org/en/download.html and the official manual.

fritzmg commented 4 years ago

http://contao.test/contao-manager.phar.php/ weitergeleitet; Prüfung durch BasicValetDriver::isStaticFile() liefert false zurück; Valet gibt 404 zurück.

Ah, you seem to have the same problem that I recently encountered, though in my case it is an Apache web server. Basically the web server is configured in a way, that URLs like https://example.com/foobar.php/lorem/ipsum/dolor aren't processed by PHP, i.e. URLs that point to a physical PHP file within the path fragments. I haven't figured out yet which config that is for Apache. Something similar needs to be configured in your case as well, probably.

But this is probably something you should ask in the Laravel community, as it is not related to Contao or the Contao Manager.

pgerundt commented 4 years ago

Versuch A: Neues Valet-Projektverzeichnis (contao) anlegen und contao-manager.phar dorthin kopieren, in .phar.php umbenennen.

You need to create a web/ subdirectory in your target directory for the Contao installation. See the instruction on https://contao.org/en/download.html and the official manual.

See attempt B. Does not work with Valet either.

fritzmg commented 4 years ago

See attempt B. Does not work with Valet either.

Yes, see new comment :)

pgerundt commented 4 years ago

Ah, you seem to have the same problem that I recently encountered, though in my case it is an Apache web server. Basically the web server is configured in a way, that URLs like https://example.com/foobar.php/lorem/ipsum/dolor aren't processed by PHP, i.e. URLs that point to a physical PHP file within the path fragments. I haven't figured out yet which config that is for Apache. Something similar needs to be configured in your case as well, probably.

But this is probably something you should ask in the Laravel community, as it is not related to Contao or the Contao Manager.

100% consent. I just wanted to make sure beforehand that it is no issue with the Contao Manager - because only /api requests result in a 404.

fritzmg commented 4 years ago

Fair enough 👍 . You could confirm that it's a general web server issue by creating your own PHP file, e.g. foobar.php, in the document root of one of your domains, with a simple echo and then access https://example.com/foobar.php/lorem/ipsum/dolor.

If you do find out, make sure to mention it here - or better yet, create a PR for the official manual :)

pgerundt commented 4 years ago

Fair enough 👍 . You could confirm that it's a general web server issue by creating your own PHP file, e.g. foobar.php, in the document root of one of your domains, with a simple echo and then access https://example.com/foobar.php/lorem/ipsum/dolor.

If you do find out, make sure to mention it here - or better yet, create a PR for the official manual :)

Oh, it's no general web server issue. If you create an index.php file, you can call it successfully with domain.test/index.php/foo/bar or domain.test/foo/bar - because that's how laravel projects work. But if you rename that file to test.php, Valet (!) gives you a 404.

But calling http://contao.test/contao-manager.phar.php/api/session gives you a 404 saying

Oops! An Error Occurred
The server returned a "404 Not Found".

Something is broken. Please let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.

And this error messages comes from the contao manager, or am i wrong?

fritzmg commented 4 years ago

But if you rename that file to test.php, Valet (!) gives you a 404.

Then it is a general web server issue and not related to the Contao Manager. You need to configure your web server, so that this works for arbitrary PHP files.

pgerundt commented 4 years ago

Then it is a general web server issue and not related to the Contao Manager. You need to configure your web server, so that this works for arbitrary PHP files.

I totally agree with you that there is an issue with Valet's ContaoValetDriver not being able to route requests to the contao-manager.phar.php. I will open an issue in laravel/valet about that.

But regarding the 404 respectively configuring the web server:

I was just wondering if anyone ever got the Contao Manager running on Laravel Valet.

aschempp commented 4 years ago

I'm closing this as it does not seem to be a Manager issue. Feel free to continue the discussion here or in the valet issue 🙃