Platform.sh User Documentation

FAQ

Upsun Beta

Access our newest offering - Upsun!

Get your free trial by clicking the link below.

Get your Upsun free trial

Why is DATABASE_URL not defined during the build hook? Anchor to this heading

During the build hook, services are not available to avoid breaking the application that is still live. That is why the Symfony integration does not expose environment variables during the build hook.

The cache:clear command does not need to connect to the database by default, except if you are using the Doctrine ORM and the database engine version is not set in your configuration.

The version information can be set in your .env file or in the doctrine.yaml configuration file. The only important pieces of information there are the database engine and the version; everything else will be ignored.

Note that the environment variables are available in the deploy hook.

How can I access my application logs? Anchor to this heading

To display the application log file (app file), run the following command:

symfony log app --tail

All the log messages generated by your app are sent to this app file. This includes language errors such as PHP errors, warnings, notices, as well as uncaught exceptions. The file also contains your application logs if you log on stderr.

Note that Platform.sh manages the app file for you. This is to prevent disks from getting filled and using very fast local drives instead of slower network disks. Make sure your apps always output their logs to stderr.

If you use Monolog, add the following configuration to your config/packages/prod/monolog.yaml file:

--- a/config/packages/prod/monolog.yaml
+++ b/config/packages/prod/monolog.yaml
@@ -11,7 +11,7 @@ monolog:
            members: [nested, buffer]
        nested:
            type: stream
-            path: "%kernel.logs_dir%/%kernel.environment%.log"
+            path: php://stderr
            level: debug
        buffer:
            type: buffer

What’s this “Oops! An Error Occurred” message about? Anchor to this heading

The Oops! An Error Occurred message comes from your app and is automatically generated based on the Symfony error template.

The server returned a “500 Internal Server Error” Anchor to this heading

A 500 error page in production mode

If your app’s working as expected locally but you see the previous error message on Platform.sh, it usually means you have a configuration error or a missing dependency.

To fix this issue, search your application logs. They likely contain an error message describing the root cause:

symfony logs all
  [app] [14-Aug-2020 10:52:27 UTC] [critical] Uncaught PHP Exception Exception: [...]
  [app]
  [php.access] 2020-08-14T10:52:27Z GET 500 2.386 ms 2048 kB 419.11% /
  [access] 78.247.136.119 - - [14/Aug/2020:10:52:27 +0000] "GET / HTTP/1.1" 500 843 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36"

If the error occurs on a preview environment, or on the main environment of a non-production project, you can also enable Symfony’s dev/debug mode to inspect the cause of the error:

# Enable debug mode
symfony env:debug
# Disable debug mode
symfony env:debug --off

The server returned a “404 Not Found” Anchor to this heading

By default, new Symfony apps come without controllers, which means there’s no homepage to show. As a result, when you run your project locally, the following welcome page is displayed:

The default Symfony welcome page in development mode

But when you run your project on Platform.sh, the following error is displayed instead:

A 404 error page in production mode

This is because Platform.sh runs in production mode, leading Symfony to show a generic 404 error. To fix this issue, create your first Symfony page.

If you’ve already created a custom homepage, make sure you perform the following actions:

  1. Commit all your files.
  2. Run the symfony deploy command and check that the deployment is successful.

Other issues Anchor to this heading

For other issues unrelated to Symfony, see Troubleshoot development.

Is this page helpful?