Skip to content

Instantly share code, notes, and snippets.

@patrickse
Last active August 29, 2015 14:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patrickse/ef02c1689bcc64fbe0da to your computer and use it in GitHub Desktop.
Save patrickse/ef02c1689bcc64fbe0da to your computer and use it in GitHub Desktop.
Setup a php project with grunt

Insperienced by http://adam.merrifield.ca/2014/10/07/yeoman-angularjs-and-php/

  1. yo angular
  2. npm install grunt-php --save-dev
  3. replace all 'connect' with 'php' inside gruntfile.
  4. add php.options.base = "app"
  5. add php.options.router = "../router.php"
  6. create router.php
<?php
// router.php

if (preg_match('/\/bower_components\/.*.css/', $_SERVER["REQUEST_URI"])) {
  header("Content-Type: text/css");
} elseif (preg_match('/\/bower_components\/.*.css/', $_SERVER["REQUEST_URI"])) {
  header("Content-Type: application/js");
}

if (preg_match('/\/bower_components\/.*/', $_SERVER["REQUEST_URI"])) {
  readfile(".." . $_SERVER["REQUEST_URI"]);
} elseif (preg_match('/bower_components\/.*/', $_SERVER["REQUEST_URI"])) {
  readfile("../" . $_SERVER["REQUEST_URI"]);
} else {
  return false;
}
  1. go to app folder
  2. composer create-project slim/slim-skeleton api
  3. go to api
  4. composer require entomb/slim-json-api
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment