Skip to content

Instantly share code, notes, and snippets.

@TiuTalk
Last active May 19, 2021 23:59
Show Gist options
  • Select an option

  • Save TiuTalk/dd18b2797f9bbddce8dc to your computer and use it in GitHub Desktop.

Select an option

Save TiuTalk/dd18b2797f9bbddce8dc to your computer and use it in GitHub Desktop.
CakePHP on Heroku

CakePHP via composer

composer.json

{
  "name": "assando-sites",
  "require": {
    "cakephp/cakephp": ">=2.5.0",
    "ext-apcu": "*",
    "ext-imagick": "*",
    "ext-memcached": "*"
  },
  "config": {
    "vendor-dir": "Vendor/"
  }
}

webroot/index.php

<?php
define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . APP_DIR . '/Vendor/cakephp/cakephp/lib');

Config/bootstrap.php

<?php
// Load Composer autoload.
require APP . '/Vendor/autoload.php';

// Remove and re-prepend CakePHP's autoloader as Composer thinks it is the
// most important.
// See: http://goo.gl/kKVJO7
spl_autoload_unregister(array('App', 'load'));
spl_autoload_register(array('App', 'load'), true, true);

.gitignore

tmp/*
app/tmp/*
!empty
Vendor

CakePHP on Heroku

config/nginx.conf

location / {
    try_files $uri @rewriteapp;
}

location @rewriteapp {
    rewrite ^(.*)$ /index.php last;
}

location ~ ^/index.php$ {
    fastcgi_pass heroku-fcgi;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param HTTPS off;
}

Procfile

web: Vendor/bin/heroku-php-nginx -C Config/nginx.conf webroot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment