In this Quick Start we are going to install the latest Phalcon REST Boilerplate. It contains predefined endpoints that serve as an example to get started.
- PHP 5.6 or newer
- Phalcon 2.0.9 or newer
- MySQL database (optional)
1. Create project
Let's start by creating a new project.
composer create-project redound/phalcon-rest-boilerplate
2. Update config files
First we want to rename the
app/configs/default.php and change the
title as well as the
description for your project.
Second, we want to rename
server.development.php and update your
hostName as well as the database settings.
3. Import database schema
Now we can import the database schema that corresponds to the endpoints already configured.
A database schema without data is also available.
4. It's working
Now we've set up everything, when we open up the browser we should see the following
Go to /documentation.html for a generated documentation of all your endpoints.
We'll be using Postman to test the endpoints that already have been set up.
Postman is a Chrome extension for building, testing and documenting API requests and keeping them organized inside collections. We are going to take advantage of that. But first we need to have it installed.
Import Postman Collection
Next, go to /export/postman.json
After clicking on "Import" in Postman we can either import the collection we saved to disk and import it manually or choose the import from link option.
We should see the imported Postman collection on the left
POST - /users/authenticate endpoint
Fill in the credentials
- Username demo
- Password test123 (is stored as bcrypt)
Update Request button, then hit the
Now we should see the
token inside our response
Make requests with token
Copy the token and click on
No environment ->
Manage environments and fill in the
token as the
authToken variable. Then, select the environment we just created.
authToken variable is send as
Authorization header as
Create your own endpoints
Look at the following concepts to replace the examples for your own implementation