# Problems with starting code

**URL:** <https://discourse.slimframework.com/t/problems-with-starting-code/5489>\
**Category:** Questions\
**Created:** [January 21, 2023, 6:50pm UTC](https://discourse.slimframework.com/t/problems-with-starting-code/5489 "2023-01-21T18:50:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Invitoacafe](https://avatars.discourse-cdn.com/v4/letter/i/46a35a/32.png) [@Invitoacafe](https://discourse.slimframework.com/u/Invitoacafe)\
**Post date:** [January 21, 2023, 6:50pm UTC](https://discourse.slimframework.com/t/problems-with-starting-code/5489/1 "2023-01-21T18:50:58Z")

</div>

Hi.  
I am starting to use Slim, step by step installing slim and Psr7 and copying the initial demo code and I always get 500 error.  
I also create the .htaccess file in the same folder ( the main folder) as index.php. I don’t understand what’s happening because I’m following the guide.  
I’m using Linux and Xamp, php 8.1, slim 4.10. I also have probe it in windows with Wamp server with identical result.

Can anyone get me some light about this?😉  
Thanks…

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [January 21, 2023, 9:34pm UTC](https://discourse.slimframework.com/t/problems-with-starting-code/5489/2 "2023-01-21T21:34:02Z")

</div>

Can you show us more error details?

---

<div class="post-metadata">

**Author:** ![Invitoacafe](https://avatars.discourse-cdn.com/v4/letter/i/46a35a/32.png) [@Invitoacafe](https://discourse.slimframework.com/u/Invitoacafe)\
**Post date:** [January 21, 2023, 10:03pm UTC](https://discourse.slimframework.com/t/problems-with-starting-code/5489/3 "2023-01-21T22:03:25Z")

</div>

When I start my app on the server in Windows Wamp I get this result…

**Fatal error** : Uncaught Slim\Exception\HttpNotFoundException: Not found. in C:\xampp\htdocs\phpslim\vendor\slim\slim\Slim\Middleware\RoutingMiddleware.php:76 Stack trace: #0 C:\xampp\htdocs\phpslim\vendor\slim\slim\Slim\Routing\RouteRunner.php(56): Slim\Middleware\RoutingMiddleware-\>performRouting(Object(Slim\Psr7\Request)) #1 C:\xampp\htdocs\phpslim\vendor\slim\slim\Slim\MiddlewareDispatcher.php(65): Slim\Routing\RouteRunner-\>handle(Object(Slim\Psr7\Request)) #2 C:\xampp\htdocs\phpslim\vendor\slim\slim\Slim\App.php(199): Slim\MiddlewareDispatcher-\>handle(Object(Slim\Psr7\Request)) #3 C:\xampp\htdocs\phpslim\vendor\slim\slim\Slim\App.php(183): Slim\App-\>handle(Object(Slim\Psr7\Request)) #4 C:\xampp\htdocs\phpslim\public\index.php(15): Slim\App-\>run() #5 {main} thrown in **C:\xampp\htdocs\phpslim\vendor\slim\slim\Slim\Middleware\RoutingMiddleware.php** on line **76**

In linux Lamp I receive this–\>

# Esta página no funciona

La página **localhost** no puede procesar esta solicitud ahora.

HTTP ERROR 500

My /public/.htaccess code

RewriteEngine On  
RewriteBase /

RewriteCond %{REQUEST\_FILENAME} !-f  
RewriteCond %{REQUEST\_FILENAME} !-d  
RewriteRule ^(.\*)$ index.php?$1 [L,QSA]

my .htaccess code

RewriteEngine On  
RewriteBase /phpslim

RewriteCond %{THE\_REQUEST} /public/([^\s?]_) [NC]  
RewriteRule ^ %1 [L,NE,R=302]  
RewriteRule ^(._)$ public/index.php?$1 [L,QSA]

and my /public/index.php code

\<?php use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; use Slim\Factory\AppFactory; require \_\_DIR\_\_ . '/../vendor/autoload.php'; $app = AppFactory::create(); $app-\>get('/', function (Request $request, Response $response, $args) { $response-\>getBody()-\>write("Hello world!"); return $response; }); $app-\>run(); All of this code is extracted of the guide. Thanks for your help.

---

<div class="post-metadata">

**Author:** ![Invitoacafe](https://avatars.discourse-cdn.com/v4/letter/i/46a35a/32.png) [@Invitoacafe](https://discourse.slimframework.com/u/Invitoacafe)\
**Post date:** [January 21, 2023, 10:43pm UTC](https://discourse.slimframework.com/t/problems-with-starting-code/5489/4 "2023-01-21T22:43:44Z")

</div>

Must be something about the Apache server because if I use this sentence

```auto
$app->setBasePath('/myapp');

```

it works, but in the official documentation indicates this as a other way to configurate the app. Well, thanks for all.

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [January 23, 2023, 4:45pm UTC](https://discourse.slimframework.com/t/problems-with-starting-code/5489/5 "2023-01-23T16:45:42Z")

</div>

The regex looks not correct to me and the basePath must be set.

Can you try this solution here?

- [GitHub - selective-php/basepath: Base path detector for Slim 4](https://github.com/selective-php/basepath#installation)
