i have a project that build on with Symfony 4.2. I want deploy this project to a shared hosting. But on symfony documentation, there is nothing about it clearly.
I deployed all my project into hosting under public_html.
But probably panel does not find the index.php. On cpanel, i can not change the document root.
current document root: public_html
my index.php under public folder.
<?php
use AppKernel;
use SymfonyComponentDebugDebug;
use SymfonyComponentHttpFoundationRequest;
require dirname(__DIR__).'/config/bootstrap.php';
if ($_SERVER['APP_DEBUG']) {
umask(0000);
Debug::enable();
}
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ??
$_ENV['TRUSTED_PROXIES'] ?? false) {
Request::setTrustedProxies(explode(',', $trustedProxies),
Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
}
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ??
$_ENV['TRUSTED_HOSTS'] ?? false) {
Request::setTrustedHosts([$trustedHosts]);
}
$kernel = new Kernel($_SERVER['APP_ENV'], (bool)
$_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
Can someone help me about this issue?
2
Answers
I have a symfony4 application running under shared hosting ,so try this configuration in the .htaccess
for assets try this in framework.yaml
People saying that symfony is not meant for this are just utterly wrong!
Symfony does not state anything about how to host it, it is (almost) completely agnostic about it’s hosting platform. The only thing you need to do is forward your server requests to the public/index.php.
I am hosting at OVH cloud, which is semi-private hosting. I got it working by pointing my domain names in the control panel to www/mysymfonyapp/public and add a .htaccess to the public directory:
Works like a charm!