Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

RC7: Cannot GET http://localhost:8080/ #287

Closed
wants to merge 1 commit into from

Conversation

weierophinney
Copy link
Member

I've tried both the standalone setup and the skeleton and I get this same error when trying to load up a page using RC7 (have not tried any other release candidates).

For the skeleton, I've done minimal setup with FastRoute, Zend ServiceManager, no templates, no error handler. This is Windows, PHP version 5.6.12, composer version 1.0-dev (ae14e0f)

I get this error (not right away, well after the page loads the error):

$ composer serve
> php -S 0.0.0.0:8080 -t public public/index.php

  [Symfony\Component\Process\Exception\ProcessTimedOutException]
  The process "php -S 0.0.0.0:8080 -t public public/index.php" exceeded the timeout of 300 seconds.

For the standalone setup, same thing, FastRoute, Zend Service manager. I followed the QuickStart Standalone usage in the docs. This is running in a Vagrant Ubuntu box, PHP version 5.6.13, composer version 1.0-dev (f1aa65). I see the same error, "Cannot GET http://....."

@geerteltink
Copy link
Member

If you get the "cannot get http" error right after the ProcessTimedOutException that is normal. Composer exists after 300 seconds on some systems. Either try it without composer php -S 0.0.0.0:8080 -t public public/index.php or set a timeout.

@kingjerod
Copy link
Contributor Author

I get the error well before the timeout. Tried it without using composer, same problem.

@weierophinney
Copy link
Member

@kingjerod The error you're reporting is one thrown by the Symfony console when reaching the timeout. Try doing the following instead of composer serve:

$ php -S 0.0.0.0:8080 -t public public/index.php

This has the benefit of sending the error log to the console, which may help us diagnose.

The next thing to point out is that if you do a minimal install, there is no middleware present to handle the request, which means you'll get a 404 every time, until you add some routes and middleware. Have you done so?

@kingjerod
Copy link
Contributor Author

Ah, did not know that about the minimal install. Added a route and it works fine (on the skeleton). I'll have to figure out why my standalone still doesn't work, I have a route there but still get a 404. Tried running it from Windows with PHP CLI like I am with the skeleton, I don't see any errors. This is all the code (from standalone docs):

<?php
use Zend\Expressive\AppFactory;

chdir(dirname(__DIR__));
require 'vendor/autoload.php';

$app = AppFactory::create();

$app->get('/', function ($request, $response, $next) {
    $response->getBody()->write('Hello, world!');
    return $response;
});

$app->run();

I'll keep poking at it.

@kingjerod
Copy link
Contributor Author

It looks like it comes from not having the 'routes' key set in the config. I was able to simplify the skeleton to this:

chdir(dirname(__DIR__));
require 'vendor/autoload.php';

use Zend\ServiceManager\Config;
use Zend\ServiceManager\ServiceManager;
use Zend\Expressive\Application;
use Zend\Expressive\Container\ApplicationFactory;

$config = [
    'dependencies' => [
        'invokables' => [
            Zend\Expressive\Router\RouterInterface::class => Zend\Expressive\Router\FastRouteRouter::class,
        ],
        'factories' => [
            Application::class => ApplicationFactory::class,
        ],
    ],
    'routes' => []
];
$container = new ServiceManager();
(new Config($config['dependencies']))->configureServiceManager($container);
$container->setService('config', $config);

$app = $container->get('Zend\Expressive\Application');
$app->get('/', function ($request, $response, $next) {
    $response->getBody()->write('Hello, world!');
    return $response;
});
$app->run();

If you delete the line where it sets 'routes' => [], it will throw a 404. I've been trying to figure out why this happens in the code, but am still trying to understand how everything is connected.

@weierophinney
Copy link
Member

@kingjerod There's a problem with the standalone quickstart: starting with RC6, we now require you to pipe the routing and dispatch middleware; however, we didn't update the standalone quickstart to reflect that. I'm going to get it updated shortly.

@weierophinney
Copy link
Member

@kingjerod I've turned this issue into a pull request, and the patch demonstrates piping the routing and dispatch middleware; please review!

@kingjerod
Copy link
Contributor Author

Looks good, tested and it works. 👍

weierophinney added a commit that referenced this pull request Jan 27, 2016
weierophinney added a commit that referenced this pull request Jan 27, 2016
@weierophinney weierophinney deleted the hotfix/287 branch January 27, 2016 18:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants