Skip to content
This repository has been archived by the owner on Jun 11, 2021. It is now read-only.

Latest commit

 

History

History
167 lines (107 loc) · 3.78 KB

README.md

File metadata and controls

167 lines (107 loc) · 3.78 KB

RESTful Bookmarks PHP Slim

TODO:

  • review and update FrontEnd

Sample application to bookmark links, where interface build with Angular.js + Twitter Bootstrap and server powered by PHP with Slim Framework, serving JSON by REST URLs.

Install Guide

Clone

$ git clone https://github.com/erkobridee/restful-bookmarks-phpslim.git
$ cd restful-bookmarks-phpslim/

Create Mysql Database

$ mysql -u DBUSERNAME -p MYSQLPASSWORD -e 'CREATE DATABASE bookmarks;'
$ mysql -u DBUSERNAME -p MYSQLPASSWORD bookmarks < bookmarks.sql

Mysql connections

edit user DBUSERNAME and MYSQLPASSWORD in api/dao/BookmarkDAO.php

...
  private function getDBConn()
  {
    $dbhost="127.0.0.1";
    $dbuser="DBUSERNAME";
    $dbpass="MYSQLPASSWORD";
    $dbname="bookmarks";
    $dbh = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpass);
    $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    return $dbh;
  }
...

XAMPP

  • Put project structure inside XAMPP /htdocs directory

Nginx example configuration

server {
  listen 127.0.0.1:80;
  access_log /var/www/restful-bookmarks-phpslim/log/access.log;
  error_log /var/www/restful-bookmarks-phpslim/log/error.log warn;

  server_name restful-bookmarks-phpslim;
  root   /var/www/restful-bookmarks-phpslim/public/;

  index  index.php index.html index.htm;
  try_files $uri $uri/ /index.php?$request_uri;

  location /rest/ {
    try_files /rest/$uri $uri/ /rest/index.php?$request_uri;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_split_path_info ^/rest/(.+\.php)(/.+)$;
    fastcgi_intercept_errors on;
    fastcgi_index  index.php;
    include fastcgi_params;
  }
}

Development with Sublime Text

  1. On Sublime Text, in menu: File > Open... select project directory location in you computer

  2. And happy coding :)

License

MIT : http://erkobridee.mit-license.org

Project build with

Helpful posts

Project REST URLs

HTTP Verbs

Project Structure

restful-bookmarks-phpslim/
  rest/
    dao/
      BookmarkDAO.php
    Slim/
      # Slim Framework files
    .htacess    # URLs map for Apache (XAMPP)
    index.php   # slim routes config
  app/
    # application files
  shared/
    # shared files with any future project
  vendor/
    # libs
  index.html
  require.config.js # require.js app config file