Setup
Installation
Composer is required.
StackSync is available as a composer package, you can install it by running the command below in your terminal while defining the targeted folder:
composer create-project khomsiadam/stacksync project-name
Alternatively, you can download or clone the repository, then open the project and run the following command in your terminal:
composer install
This installs the dependencies for php-jwt and phpdotenv which are the only required packages.
Configuration
After creating your database, in your root directory, you will find a .env.example
file. Copy and rename to .env
and start filling in your database informations.
# Database Credentials: *fill with your proper database information
DB_HOST=
DB_NAME=
DB_USER=
DB_PASS=
# Data Source Name: *do not modify! $_ENV['DSN'] is used as first argument for your PDO connection
DSN=mysql:host=${DB_HOST};dbname=${DB_NAME}
# Errors and responses status for error handling for the API:
ERRORS=ON
RESPONSES=ON
# Database User Table:
USER_TABLE=user
# Database User Columns (add any needed variable for every column added in user table):
USER_ID=user_id
USER_EMAIL=email
USER_PASSWORD=password
# Database Audience Table: *The recipient table for account for 'aud' in JWT token payload
AUDIENCE_TABLE=
# Database Other Tables: *Other tables you may need, as argument for your CRUD operations in controller methods
EXAMPLE_TABLE=
# API Token Authentication Secret Keys: *fill with your own key or add new keys as needed
SECRET_KEY=
- DB_HOST: hostname.
- DB_NAME: database name.
- DB_USER: username.
- DB_PASS: password.
- DSN: short for Data Source Name (*do not modify).
- ERRORS: enable or disable error handling.
- RESPONSES: enable or disable response messages during API requests.
- USER_TABLE, USER_ID, USER_EMAIL, USER_PASSWORD: the name of the users table and its columns that will be created through migration. The default table is `user` and the default columns are `user_id`, `email` and `password` respectively.
- AUDIENCE_TABLE: the audience targeted table of the API.
- SECRET_KEY: the secret key to generate your JWT token.
*Only modify if you plan on creating your own tables with no migrations.
Welcome
Opening your terminal, navigating to your project folder:
cd project-name
Then running this command:
composer serve:local
Will run PHP's built in development server on your local machine and browsing to `http://localhost:8080` will show a welcome homepage.