Search code examples
phplaravelswisscomdev

Folder public/vendor does not get uploaded with cf push


I am currently trying to set up a Laravel 5.6 project on Swisscom Application Cloud using the php-buildpack.

Unfortunately, my public/vendor folder does not get uploaded or gets deleted once uploaded after cf push. If I connect using cf ssh and navigate to the public folder, there is no vendor folder inside. I tried everything including removing everything from .cfignore.

options.json

{
  "LIBDIR": "vendor",
  "WEBDIR": "public",
  "PHP_VERSION": "{PHP_70_LATEST}",
  "COMPOSER_VENDOR_DIR": "vendor",
  "PHP_EXTENSIONS": [ "bz2", "zlib", "openssl", "tokenizer", "curl", 
  "mcrypt", "mbstring", "pdo", "pdo_mysql", "fileinfo", "gd", 
  "pdo_sqlite"],
  "PHP_MODULES": ["fpm", "cli"],
  "ADDITIONAL_PREPROCESS_CMDS": [
    "php artisan migrate --force",
    "php artisan config:cache"
  ]
}

If I copy my public/vendor folder to public/vendor2, the folder is available on the server after cf push.

Edit: I need to mention that the public/vendor folder is not the folder created by executing composer install but includes all css/html/js files which need to be publicly available. They need to be added locally as some of them need to be built with npm or modified.


Solution

  • There is an issue with the PHP buildpack that makes cf push ignore all folders with vendor as the name.

    As a workaround, you could create a symlink, for example, you could use a dir named my-vendor and create a symlink to it using vendor as the name:

    $ cd public
    $ mkdir my-vendor
    $ ln -s my-vendor vendor
    

    After deploying cf push . you could veryfy via cf ssh . and should have the symlink created public/vendor, something like this:

    vcap@aceb5ff2-a9dc-41f4-50be-f234:~/app/public$ ls -al app/public/
    total 8
    drwxr-xr-x 3 vcap vcap   54 Aug  2 14:13 .
    drwxr-xr-x 1 vcap root 4096 Aug  2 14:13 ..
    -rw-r--r-- 1 vcap vcap  501 Aug  2 14:01 index.php
    drwxr-xr-x 2 vcap vcap   36 Aug  2 13:50 my-vendor
    lrwxrwxrwx 1 vcap vcap    9 Aug  2 13:50 vendor -> my-vendor