First project, Problems to use the slim skeleton [SOLVED]

Hello guys!

Its is a basic thing but i’m in trouble to start my slim-path. so i will really appreciate your help.

As the main slim tutorial ask, i used the composer to get the slim-skeleton project into my www apache folder:


but instead of the embedded php web server i’m using the apache2 web server.

here is my apache config sites-avaliable:

and apache2.conf

so , when i go to browser: at: localhost/saa

if i go to “public” folder i get this result: HTTP ERROR 500.

i have tried to change the DocumentRoot to “/var/www/html/saa/public”

but after restart apache i got the same result: HTTP ERROR 500.

seems like a rewriter rule or redirect error, but i have no idea to solve this.

Can anyone help me to fix this and return my focus to learn the slim?

I have a very simple fix for you to get Slim 3 running in a subdirectory:

Create a new file: /var/www/html/saa/.htaccess

Content of .htaccess

RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]

In your dependencies.php or wherever you add your Service Factories:


// ....

$container['environment'] = function () {
    $scriptName = $_SERVER['SCRIPT_NAME'];
    $_SERVER['REAL_SCRIPT_NAME'] = $scriptName;
    $_SERVER['SCRIPT_NAME'] = dirname(dirname($scriptName)) . '/' . basename($scriptName);
    return new Slim\Http\Environment($_SERVER);

// ...

Now you can open the app via: http://localhost/slim3-app.

1 Like

Hi odan, thanks for you help. but didn’t work to me…

I have followed this steps:

  1. Install the slim-skeleton by composer (composer.phar create-project slim/slim-skeleton slim3-app ) inside of “/var/www/html”
    2 - Created a .htaccess inside the slim3-app/.htaccess
    3 - edit the “slim3-app/src/dependencies.php” and add your snippet of code.
    4 - My documentRoot it’s mapped to: “/var/www/html”
    5 - i added th code in my git :

So when i access " http://localhost:8888/slim3-app."

I received this error:

I don’t know what it is happens… it is really complex to me use the slim3-skeleton project.

Any ideas?

Your documentroot should be mapped to /var/www/html/slim3-app/public, since that is where you installed it. The .htaccess would therefore be at /var/www/html/slim3-app/public/.htaccess. Then you would access it from http://localhost:8888. If you still get an error, look inside Apache’s error log to find the specific error. The one you see on the page is generic. Apache’s error log will give you more precise details as to what is going wrong.

1 Like

Hi @tflight i’ve made your rocommend modifications.

  1. Now my my documentRoot is its mapped to “/var/www/html/slim3-app/public”,

  2. So when o use the browser (localhost:8888) the error 500 persists.

  3. The apache error.log show the following error:
    [Sat Dec 02 14:46:49.400920 2017] [:error] [pid 407] [client] PHP Fatal error: require(): Failed opening required '/var/www/html/slim3-app/public/../vendor/autoload.php' include_path='.:/usr/share/php') in /var/www/html/slim3-app/public/index.php on line 12

  4. the index.php on line 12 its looking a vendor directory… but there is no “vendor/” inside the slim-skeleton project

  5. My folders structure (slim-skeleton from composer command)

What do you think about? Am i doing something wrong or there is some possibility of the slim-skeleton it is out of date and is missing the “vendor” directory?

If you followed the instructions you should have that directory.

cd into your project directory and run composer install.

1 Like

hahaha! it working!!! oh man really thanks for your help. after run the comporser install i saw that was missing some importants php modules, and for this reason the verdor folder and other slim things was missing.

but now it is everything working. Now i will go on with my studies.

Tranks bro!