Congratulations! if you have made it this far, that means you have successfully built something awesome using Slim. However, the time to party has not come yet. We still have to push our application to the production server.
There are many ways to do this that are beyond the scope of this documentation. In this section, we provide some notes for various set-ups.
<?php use Slim\Factory\AppFactory; use Slim\Middleware\ErrorMiddleware; require __DIR__ . '/../vendor/autoload.php'; $app = AppFactory::create(); ... /** * If you are using the pre-packaged ErrorMiddleware * Ensure that you set the third parameter of ErrorMiddleware's constructor to false */ $callableResolver = $app->getCallableResolver(); $responseFactory = $app->getResponseFactory(); $errorMiddleware = new ErrorMiddleware($callableResolver, $responseFactory, false, true, true); $app->add($errorMiddleware); ... $app->run();
You should also ensure that your PHP installation is configured to not display
errors with the
display_errors = 0
If you control your server, then you should set up a deployment process using any one of the many deployment system such as:
Review the Web Servers documentation to configure your webserver.
If your shared server runs Apache, then you need to create a
in your web server root directory (usually named
www) with the following content:
<IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^$ public/ [L] RewriteRule (^[^/]*$) public/$1 [L] </IfModule>
(replace ‘public’ with the correct name of your domain name e.g. example.com/$1)
Now upload all the files that make up your Slim project to the webserver. As you are on shared hosting, this is probably done via FTP and you can use any FTP client, such as Filezilla to do this.