Here you have yet another framework for writing RESTful web services in PHP

Overview

PHP-Rocker

Here you have yet another framework for writing RESTful web services in PHP, jay! What sets this framework apart from many of the others is that PHP-Rocker is a bundle of Slim and an awesome database facade. Not trying to write everything from scratch makes it possible for you to focus on what's important when writing your RESTful API and let other projects take care of things like routing and data storage.

Features

  • User management
  • CRUD operations Use the base classes in PHP-Rocker to extend the API with your own objects and operations
  • EAV data model
  • Static file storage With support for image manipulation and storage on Amazon S3
  • Built in object cache With support for APC and file based caching
  • Interface based Easy to extend and to customize
  • Administer remote servers from the console
  • Automatically generated documentation Extracts all info from class files, meaning that you only have to write your documentation once

Read more

Additional packages

  • Facebook login Integrate your PHP-Rocker server with Facebook
  • Google login Enable authenticated request with user credentials from Google

System requirements

  • PHP v >= 5.3.2
  • MySQL The database layer has support several different databases (oracle, mssql, postgresql...) but PHP-Rocker is so far only tested with MySQL
  • Web server (apache/nginx) If using nginx the .htaccess rewrite rules has to be moved to the rewrite configuration of the server

Installation

1) Add file composer.json to your application directory with the following json configuration (notice that you must allow dev packages):

{
    "minimum-stability": "dev",
    "require" : {
        "rocker/server": "1.2.6"
    }
}

2) Run composer install in your application directory. This will install Slim and all other packages that PHP-Rocker is dependent on.

$ composer install

3) Run vendor/rocker/server/install.php in your application directory

$ php -f vendor/rocker/server/install.php

- You're done!

API reference

The API reference has moved to its own wiki page.

Extending the API with more operations

Here you can read more about how to create custom operations

Adding your own objects

Here you can read more about how to add your own objects

Manage remote servers via command line

First of move the console program to your bin directory so that you can access it from anywhere.

$ sudo ln -s /path/to/your/rocker/installation/console /bin/rocker

Having done that you add your server (you'll be prompted for server address and user credentials)

$ rocker server

Search for users

=80&description=*hockey*|*soccer*' ">
# Find users with nick containing John
$ rocker users -q 'nick=*John*'

# Find users coming from either France or Germany that is not admin
$ rocker users -q 'country=France|Germany&admin!=1'

# Find users that has a score greater than 80 and that has a description
# containing either "hockey" or "soccer"
$ rocker users -q 'score>=80&description=*hockey*|*soccer*'

Load user data

$ rocker users -l [email protected]

You can also create, delete and update the users using the console program. Run rocker in the console to get more help.

A note on security

PHP-Rocker supports basic authentication and RC4 encrypted authentication out of the box. You should always run your web services on a SSL cert when handling business/user data, especially if you're using basic authentication. The RC4 encrypted authentication works basically the same as basic authentication except that the user credentials is encrypted on the client and decrypted on the server using a shared secret. If wanting to run RC4 encrypted requests you'll need to modify the parameter application.auth in config.php.

'what-ever-hard-to-guess-string-you-want' )">
'application.auth' => array(
    'class' => '\\Rocker\\REST\\Authenticator',
    'mechanism' => 'RC4 realm="your.service.com"',
    'secret' => 'what-ever-hard-to-guess-string-you-want'
)

The secret also has to be given to the client communicating with your Rocker server. Pseudo code:

String crypted = RC4.encrypt("the-hard-to-guess-secret", "[email protected]:some-password");
request.addHeader("Authorization", "RC4 " + Base64.encode(crypted));

Other authentication packages

  • Facebook login Integrate your PHP-Rocker server with Facebook
  • Google login Enable authenticated request with user credentials from Google

Auto-generated documentation

The documentation is automatically generated from the operation classes defined in config.php. The class documentation, URI of the operation and the allowed request methods will be added to the generated documentation. Take a look at index.php to see how the documentation is added to Slim's routing-system, you can also change to a template of your own.

Auto-generated documentation

Unit and acceptance testing

To run the unit tests of Rocker navigate to libs/Test and run phpunit. You can also run acceptance tests on your entire infrastructure using the dokimon tests

License

MIT license

Road map

  • Support file storage on Amazone S3
  • Write the authentication method as a Slim middleware
  • Make it possible to store blob data using PUT
  • Look into using another data model for stored objects (maybe support noSQL)
  • Add support for XML formatted responses
  • Rewrite the console program as a phar and move the source code to a separate project

Changelog

1.3.0 (unreleased)

  • Auto-generated documentation

1.2.6

  • Client can now determine the content type of the server response by adding .json or .xml to the URI

1.2.0

  • General improvements and minor bug fixes
  • Simplified install procedure

1.1.8

  • Trying to update a user with an already registered e-mail address now results in http status
    409 instead of 400
  • Abstract object factories now implements InstallableInterface
  • Improved install script, all classes that should run install when app is installed is now declared in config.php
  • Added configuration options for user management and file storage
  • Access-Allow-Headers is now only sent when request method is OPTIONS
  • Improved database queries made when calling AbstractObjectFactory::metaSearch()
  • XML content type is now supported
  • Improved console method displaying available servers

1.1.7

  • General improvements in PHP-Rocker\Object\ObjectMetaFactory
  • Fixed bug that made the code to iterate over null variable
  • Replaced logic for image manipulation with Gregwar/Image
  • Fixed bug that sometimes made the console program to crash

1.1.6

  • Added support for file storage
  • Added functionality for image manipulation
You might also like...
Littlelink admin is an admin panel for littlelink that provides you a website similar linktree.

⚙️ LittleLink Admin LittleLink Admin is an admin panel for littlelink that provides you a website similar linktree. 📑 Features creating a link page w

Littlelink admin is an admin panel for littlelink that provides you a website similar linktree.

LittleLink Admin is an admin panel for littlelink that provides you a website similar linktree.

Laravel Admin Dashboard, Admin Template with Frontend Template, for scalable Laravel projects. It is to save your time when You start with new scalable Laravel projects with many features Bootstrap, cooreui, infyom admin Generator, roles and  permissions, translatable models, spatie media and much more Wave - The Software as a Service Starter Kit, designed to help you build the SAAS of your dreams 🚀 💰
Wave - The Software as a Service Starter Kit, designed to help you build the SAAS of your dreams 🚀 💰

Introduction Wave is a Software as a Service Starter Kit that can help you build your next great idea 💰 . Wave is built with Laravel, Voyager, Tailwi

With this package you can create wallet for the users.

Laravel User Wallet With this package you can create wallet for the users. Note: Make sure you've already installed php ^8 Installation Install the pa

Admin Columns allows you to manage and organize columns in the posts, users, comments, and media lists tables in the WordPress admin panel.

Admin Columns allows you to manage and organize columns in the posts, users, comments, and media lists tables in the WordPress admin panel. Transform the WordPress admin screens into beautiful, clear overviews.

This is a Starter Laravel 8 project with Vue 3 and Bootstrap 5 installed for you.

Laravel8-Vue3-Bootstrap5 This is a Starter Laravel 8 project with Vue 3 and Bootstrap 5. Instalation Guide: As always you need to: composer install Th

A Laravel package which helps you automate creation of files.
A Laravel package which helps you automate creation of files.

Laravel file generator This is a Laravel package which helps you automate creation of files. High Res Link Benefits If you create a type of file frequ

Boilerplate between the Magento API and ImportExport, so that you can do fast Array/XMLRPC/SOAP based product imports.

Boilerplate between the Magento API and ImportExport, so that you can do fast Array/XMLRPC/SOAP based product imports.

Aww CRUD, here we go again

Aww CRUD, here we go again This is a team assignment which will teach us how to connect to a database, write a simple Create, Read, Update and Delete

null 0 Jul 13, 2022
a simple and secured RESTful API made with codeIgniter and JSON Web Tokens

CodeIgniter 4 Application Starter What is CodeIgniter? CodeIgniter is a PHP full-stack web framework that is light, fast, flexible and secure. More in

null 2 Oct 8, 2021
This package provides an artisan command to generate a basic crud with Restful API support

NHRROB Crud Generator Package This package provides an artisan command to generate a basic crud composer install command: composer require nhrrob/crud

Nazmul Hasan Robin 22 Jun 24, 2022
Prepare your Laravel apps incredibly fast, with various commands, services, facades and boilerplates.

Grafite Builder Grafite has archived this project and no longer supports or develops the code. We recommend using only as a source of ideas for your o

Grafite Inc 997 Dec 22, 2022
LittleLink Custom provides you with a website similar to Linktree. Many social media platforms only allow you to add one link

LittleLink Custom is a fork of LittleLink Admin with a set goal of making the admin panel easier to use and setup, for inexperienced and first-time users, with the addition of many custom features themed around customization for the individual user's, LittleLink pages.

Julian Prieber 612 Jan 3, 2023
Web Sekolah yang dibuat diatas CMS Popoji dengan base Laravel 6. Web Sekolah ini sudah diintegrasikan dengan template semesta-front.

Web Sekolah yang dibuat diatas CMS Popoji dengan base Laravel 6. Web Sekolah ini sudah diintegrasikan dengan template semesta-front.

Muhamad Ramdani Hidayatullah 1 Feb 6, 2022
Very simple CRUD project, written in pure php. Designed as framework-agnostic as possible, and with basically no stack overflow if you can believe that

briefly simple CRUD pure php project for self improvement I try to make it purely in github - not only code, but any documentation (wiki), tasks (issu

Michał Jędrasiak 1 Jan 23, 2022
A Web Artisan list of categorized OPEN SOURCE PROJECTS built with Laravel PHP Framework.

Laravel-Open-Source-Projects A Web Artisan list of categorized OPEN SOURCE PROJECTS built with Laravel PHP Framework. This repository includes a compr

Goodness Toluwanimi Kayode 833 Dec 26, 2022
Laravel API starter Kit will provide you with the tools for making API's that everyone will love

Laravel API Starter Kit Laravel API starter Kit will provide you with the tools for making API's that everyone will love, API Authentication is alread

Jose Luis Fonseca 400 Dec 29, 2022
Kick-start laravel prepared package for you!

Laravel Platform Install For development composer install npm install npm run dev ?? npm run prod php artisan migrate --seed For testing composer ins

Nejc 6 Sep 16, 2022