Skip to content

lamisb/PHP-Boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Boilerplate

Boilerplate for setting up PHP 7 with composer PSR4 and phpunit

NOTE I advice you to use vagrant and not mess with your mac

MAC Pro Development Environment Steps:

$ brew tap homebrew/dupes
$ brew tap homebrew/php
$  brew install php71
  • To launch php-fpm on startup: mkdir -p ~/Library/LaunchAgents cp /usr/local/opt/php71/homebrew.mxcl.php71.plist ~/Library/LaunchAgents/ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php71.plist
  • also make sure that /usr/loca/sbin is loaded first in $PATH otherwise edit it
  • install composer and phpunit
$ brew install composer
$ brew install phpunit
  • Install Nginx
$ brew install nginx
  • Modify nginx in /usr/local/etc/nginx/
$ cd /usr/local/etc/nginx
$ mkdir sites-available
$ mkdir sites-enabled
$ touch sites-available/deafult.conf
$ cd sites-enabled
$ ln ../sites-available/default.conf
  • add the following configuration to default.conf
server {

   listen       80;
   server_name ~^(?<name>.+)\.lb$;
   set $baseroot /Users/Lamis/Developer;
   set $root $baseroot;
   
   if ($name) {
       set $root $baseroot/$name/public;
   } 
  
   root $root;
   index index.php index.html;
   try_files $uri $uri/ /index.php?$args;
   error_log /usr/local/var/log/nginx_error.log error;

    #access_log  logs/host.access.log  main;

   location ~ ^(.+\.php)(?:/.+)?$ {
       expires off;
       proxy_read_timeout 600;
       proxy_connect_timeout 600;
       fastcgi_pass 127.0.0.1:9000;
       fastcgi_index index.php;
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       fastcgi_split_path_info ^(.+\.php)(/.*)$;
       fastcgi_connect_timeout 60;
       fastcgi_send_timeout 180;
       fastcgi_read_timeout 180;
       fastcgi_buffer_size 1m;
       fastcgi_buffers 4 1m;
       fastcgi_busy_buffers_size 1m;
       fastcgi_temp_file_write_size 1m;
       fastcgi_intercept_errors on;
       include fastcgi_params;
   }

   location ~ /\. {
       deny  all;
   }
}
  • add the following line to nginx.conf inside http{}
 include /usr/local/etc/nginx/sites-enabled/*.conf;
  • sudo nginx -s reload
  • you might need to kill the php-fpm service
lsof -i :9000
kill -9 {port}
  • modify host file sudo vim /private/etc/hosts

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published