Slim Deploy Error

#1

**Slim Deploy 500 Error

My Project Structure

**

Public/index.php

    <?php
    require __DIR__.'/../bootstrap/app.php';
    $app->run();
    ?>

bootstrap/app.php

<?php

require __DIR__.'/../vendor/autoload.php';
require 'config.php';

session_start();

$app = new \Slim\App([
    'settings' => [
        'displayErrorDetails' => false
    ]
    ]);

$container = $app->getContainer();

$container['auth'] = function ($container) {
    return new \App\Auth\Auth;
};

$container['flash'] = function ($container) {
    return new \Slim\Flash\Messages;
};

$container['view'] = function ($container) {
    $view = new \Slim\Views\Twig(__DIR__ .'/../resourses/views', [
        'cache' => false,
    ]);

$container['errorHandler'] = function ($container) {
    return function ($request, $response, $exception) use ($container) {
        // retrieve logger from $container here and log the error
        $response->getBody()->rewind();
        return $response->withStatus(500)
                        ->withHeader('Content-Type', 'text/html')
                        ->write("Oops, something's gone wrong!");
    };
};
    
$container['phpErrorHandler'] = function ($container) {
    return function ($request, $response, $error) use ($container) {
        // retrieve logger from $container here and log the error
        $response->getBody()->rewind();
        return $response->withStatus(500)
                        ->withHeader('Content-Type', 'text/html')
                        ->write("Oops, something's gone wrong!");
    };
};

   $view->getEnvironment()->addGlobal('flash', $container->flash);

    $view->addExtension(new Slim\Views\TwigExtension(
        $container->router,
        $container->request->getUri()
    ));

    return $view;
};


require __DIR__. '/../routes/web.php';

any help how to deploy online hosting

0 Likes

#2

Hello!

Error 500 is a very general error message.
Did you try to activate the error details?

'displayErrorDetails' => true

Also check the server error logfiles.

0 Likes

#3

HTTP ERROR 500

unable to handle a
request

is this Path is correct : DIR.’/…/vendor/autoload.php on online hosting

0 Likes

#4

Can you please deploy this Slim 3 Hello World App on your host and tell me if it works?

0 Likes

#5

“Unable to handle request” is not message from your php application; it is server (apache?) error

it will be error in your configuration (htaccess, vhost?)
also it is possible that you had deployed your files without sufficient rights

you need to open your server error log and investigate issue, start with server(apache?) error log, then application (php) error log

0 Likes

#6

i’m Use shared hosting

0 Likes

#7

Problem Solved,
try the same method 5-6 times but not work
last same method work

:upside_down_face:
I don’t know what problem

but thanks everybody

0 Likes