3

I've installed Slim4 via composer by following the installation guide command,

php composer.phar create-project slim/slim-skeleton slimexample

Then went to localhost:8080 which returned a json object as below.

{
  "statusCode": 404,
  "error": {
    "type": "RESOURCE_NOT_FOUND",
    "description": "Not found."
  }
}

Any help on this on how to get started to run my first slim

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
amachree tamunoemi
  • 817
  • 2
  • 16
  • 33

2 Answers2

1

This is expected behavior. There is no route for '/', see https://github.com/slimphp/Slim-Skeleton/blob/4.0.1/app/routes.php

Only valid routes are

  • /users
  • /users/{id}

Therefore Slim returns 404 error code correctly.

(This omission has been addressed in 4.0.2)

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
Simon Berka
  • 378
  • 1
  • 9
  • This is not correct. [Line 14 of the file]((https://github.com/slimphp/Slim-Skeleton/blob/master/app/routes.php#L14) defines a route callback for `/`, which shows "Hello world!" to the user. – Nima Aug 19 '19 at 16:03
  • Yes, because the route was added in commit https://github.com/slimphp/Slim-Skeleton/commit/3ba4d97b5bee002385859357ab3107df99df37f3 few hours after I wrote my answer here... – Simon Berka Aug 19 '19 at 17:22
-1

You were creating a slim project here with composer. after creation of the project are you starting with composer.

cd slimexample
php composer.phar start

Check this resource for more information