简体   繁体   中英

Server error slim framework php

I have a problem with Slim framework.I tried to display hello world on screen but it gives me the error:

 Server run an intern error and couldn't resolve your request.The server is overloaded or it was an error in a script CGI.
 Error 500

My index.php

<?php

require __DIR__ . '/vendor/autoload.php';
$app = new \Slim\Slim();

$app->get('/hello', function () {
   echo "Hello";
});
$app->run(); ?>

and my .htaccess

 RewriteEngine On
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-F
 RewriterULE ^ index.php [QSA, L]

I also modify in httpd.conf with the lines:

 <Directory />
   Options All
   AllowOverride All
</Directory>

So when I write http://localhost/monologTree/hello it gives me the error from the start. Any suggestions? Thank you

Check your composer.json file. I think you have installed slim 3. Then Try to instantiate slim like this

require 'vendor/autoload.php';
$app = new Slim\App();

Check this example for properly use Slim from installation.

The 2nd solution is Find the file called httpd.conf, it should be located in **XAMPPInstallDirectory\\apache\\conf**

Open with notepad and find this line

#LoadModule rewrite_module modules/mod_rewrite.so

Remove the # , save it, restart apache (if running).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM