This repository contains an application skeleton for creating REST-based Web services. The latest version of the Slim micro framework is being used.
Follow the instructions below in the specified order:
- Download this repository as
.zip
file. - Extract the downloaded
slim-template-main.zip
file locally. - Copy the
slim-template-main
folder into your Web server's document root (that is,htdocs
) - Rename the
slim-template-main
folder to[project_name]-api
. For example,worldcup-api
- Open your
[project_name]-api
folder in VS Code - Open a terminal window in VS Code (hit
Ctrl+`
), and run the following command to install or update the required dependencies in a VS Code terminal window (hitCtrl+`
)
composer.bat update
NOTE:
You can always clone this repository. However, if you do, you need to remove the .git
hidden directory before you copy this template over to htdocs
The database credentials info are stored in app/config/app_config.php
.
- Change the value of DB_NAME constant to reflect the name of the database to be used by your slim app.
- You may also want to change the database connection credentials in that file.
Do not use .env
files for storing environment specific application settings/configurations. Dotenv is not meant to be used in production
Just Google: "DB_PASSWORD" filetype:env Google
Instead, follow the instructions that are detailed in config/env.example.php
Below are keybindings that speeds up the insertion of special characters and keywords while editing a .php
file. These bindings need to be added to your VS Code's keybindings.json
{
"key": "alt+shift+j",
"command": "type",
"args": { "text": "=>" },
"when": "editorTextFocus"
},
{
"key": "alt+shift+h",
"command": "type",
"args": { "text": "<?php" },
"when": "editorTextFocus"
},
{
"key": "alt+shift+l",
"command": "type",
"args": { "text": "$this->" },
"when": "editorTextFocus"
},
{
"key": "alt+shift+k",
"command": "type",
"args": { "text": "->" },
"when": "editorTextFocus"
},
{
"key": "shift+enter",
"command": "type",
"args": { "text": "$" },
"when": "editorTextFocus"
},
{
"key": "shift+space",
"command": "type",
"args": { "text": "_" },
"when": "editorTextFocus"
}
The following dependencies have been already added to this template.
slim/slim:"4.*"
guzzlehttp/guzzle
firebase/php-jwt
monolog/monolog
Optional: you can use composer
to either update the referenced dependencies or add additional ones based on your implementation's requirements.
Listed below are recommended VS Code extensions for Web development. However, most of them are already included in .vscode/extensions.json