Search code examples
laravelcloud-foundryswisscomdev

Deploy a Laravel App on Cloudfoundry


I am trying to deploy a Laravel based web application to the Swisscom Application Cloud. Therefor I use the provided PHP Buildpack. The Docs shows an example with Lumen, so I am assuming that it should work with Laravel as well.

Used command: cf push app-name -m 512M -n app-name

While deploying I get these two errors:

a)

The extension 'fpm' is not provided by this buildpack.
The extension 'tokenizer' is not provided by this buildpack.
The extension 'dom' is not provided by this buildpack.
The extension 'json' is not provided by this buildpack.
The extension 'pcre' is not provided by this buildpack.
The extension 'reflection' is not provided by this buildpack.
The extension 'spl' is not provided by this buildpack.

b)

Generating autoload files
> Illuminate\Foundation\ComposerScripts::postInstall
> php artisan optimize
PHP Warning:  require(/tmp/app/bootstrap/../vendor/autoload.php):failed to open stream: No such file or directory in /tmp/app/bootstrap/autoload.php on line 17
PHP Fatal error:  require(): Failed opening required '/tmp/app/bootstrap/../vendor/autoload.php'(include_path='../lib/php:/tmp/app/lib') in /tmp/app/bootstrap/autoload.php on line 17
Script php artisan optimize handling the post-install-cmd event returned with an error

My options.json file:

{
   "WEBDIR": "public",
   "PHP_VERSION": "{PHP_70_LATEST}",
   "PHP_EXTENSIONS": [ "bz2", "zlib", "openssl", "fpm", "tokenizer", "curl", "mcrypt", "mbstring", "pdo", "pdo_mysql"]
}

Thank you for your help!


Solution

  • I've found the solution. Simply add

    "COMPOSER_VENDOR_DIR": "vendor",
    

    to your options.json file.

    {
    "PHP_VERSION": "{PHP_70_LATEST}",
    "WEBDIR": "public",
    "LIBDIR": "vendor",
    "COMPOSER_VENDOR_DIR": "vendor",
    "PHP_EXTENSIONS": [ "bz2", "zlib", "openssl", "fpm", "tokenizer", "curl", "mcrypt", "mbstring", "pdo", "pdo_mysql"]
    }
    

    More information in the Docs