Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

skoobi's avatar
Level 13

No application encryption key has been specified.

Hi. Ive got a project on Forge which has been working fine till this morning.

Im getting this error::

Cloning into 'testing.expo.trst'...
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Package operations: 8 installs, 0 updates, 0 removals
  - Installing stripe/stripe-php (v5.9.2): Loading from cache
  - Installing sabberworm/php-css-parser (8.1.0): Loading from cache
  - Installing phenx/php-svg-lib (v0.3.2): Loading from cache
  - Installing phenx/php-font-lib (0.5.1): Loading from cache
  - Installing dompdf/dompdf (v0.8.2): Loading from cache
  - Installing laravel/cashier (v7.1.1): Loading from cache
  - Installing maximebf/debugbar (v1.15.0): Loading from cache
  - Installing barryvdh/laravel-debugbar (v3.1.5): Loading from cache
maximebf/debugbar suggests installing kriswallsmith/assetic (The best way to manage assets)
maximebf/debugbar suggests installing predis/predis (Redis storage)
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover

In EncryptionServiceProvider.php line 42:
                                                     
  No application encryption key has been specified.  
                                                     

Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1

I tried to remove the domain and re create it, importing the project from scratch, but i still get the same error.

Any ideas

Cheers Chris

0 likes
5 replies
tykus's avatar

Check your Environment Variables, You need to run php artisan key:generate to set the application key in a .env file; or set a vlaid key in the server's environment.

If using the .env file, make sure you also have one perhaps by copying the .env.example

skoobi's avatar
Level 13

Cheers for the reply, but tried all that. It works on localhost and has been working on Forge using DO for the last week, but tried pushing new code to Forge this morning and i get that error.

I then deleted that site and created a new site on Forge i don't get the option to set a new key or the environment in till its been pulled successfully.

tykus's avatar

Weird that a key is required at that stage of the deployment workflow. Is there anything custom running in your postInstall scripts?

You could temporarily set the application key directly in the config/app.php as the fallback value to the env() helper:

// config/app.php

return [
    // ...

    'key' => env('APP_KEY', 'base64:W1uTE/vOUap4Tp//xFWhDKBt0AARfs21X+7WXWeE5mk='),

    // ...
];

skoobi's avatar
Level 13

Hi, Nothing custom in the post install. When i set the key in app.php i get another error. I don't quite understand whats going on! As it all works perfect on the localhost and was working perfect on the test server using forge, but after the last commit it throws all these errors after working for so long.

Ive removed composer.lock and run composer install but nothing. Also run artisan dump-autoload and still nothing.

Many thanks for the input so far :)

Thu Jun 7 06:03:19 UTC 2018
From bitbucket.org:cloudwales/app
 * branch            master     -> FETCH_HEAD
Already up-to-date.
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover

   Symfony\Component\Debug\Exception\FatalThrowableError  : Class 'Illuminate\Foundation\Console\ObserverMakeCommand' not found

  at /home/forge/testing.expost.uk/vendor/laravel/framework/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php:614
    610|      */
    611|     protected function registerObserverMakeCommand()
    612|     {
    613|         $this->app->singleton('command.observer.make', function ($app) {
  > 614|             return new ObserverMakeCommand($app['files']);
    615|         });
    616|     }
    617| 
    618|     /**

  Exception trace:

  1   Illuminate\Foundation\Providers\ArtisanServiceProvider::Illuminate\Foundation\Providers\{closure}(Object(Illuminate\Foundation\Application), [])
      /home/forge/testing.expost.uk/vendor/laravel/framework/src/Illuminate/Container/Container.php:764

  2   Illuminate\Container\Container::build(Object(Closure))
      /home/forge/testing.expost.uk/vendor/laravel/framework/src/Illuminate/Container/Container.php:646

  Please use the argument -v to see more details.
Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1
skoobi's avatar
skoobi
OP
Best Answer
Level 13

After a week of trying to get things working, it turned out to be Forge. Logged into server and pulled repository from there and it all worked.

Then after that i tried a different method where I pulled the repository in Forge but unchecked install composer dependancies. This pulled in the project repository. Then logged into the server and updated composer there, and that all worked. Now when i push to git it deploys successfully.

Not sure why I had this issue...

Anyway hope this helps someone down the line...

Please or to participate in this conversation.