This repository contains an application skeleton for creating REST-based Web services using the latest version of the Slim micro framework.
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 runcomposer.bat update
command to install or update the required dependencies. Make sure thatCommand Prompt
is selected (the dropdown menu in the upper-right corner). - Adjust your database credentials, see below.
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
Follow the outlined instructions in config/env.example.php
- Change the value of the
database
variable to reflect the name of the database to be used by your slim app. - You may also want to change the connection credentials in that file.
Sensitive information used in app such as your database credentials, API key, etc. MUST not be pushed into your Git repo.
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
-
Open your VS Code installation folder,
-
Navigate to:
resources > app > out > vs >code > electron-sandbox > workbench
-
Open
workbench.js
in a text editor, -
Add the following to the end of
workbench.js
then save it,var styleNode = document.createElement('style'); styleNode.type = "text/css"; var styleText = document.createTextNode(` @font-face{ font-family: 'Fira Code'; src: url('https://raw.githubusercontent.com/tonsky/FiraCode/master/distr/eot/FiraCode-Regular.eot') format('embedded-opentype'), url('https://raw.githubusercontent.com/tonsky/FiraCode/master/distr/woff2/FiraCode-Regular.woff2') format('woff2'), url('https://raw.githubusercontent.com/tonsky/FiraCode/master/distr/woff/FiraCode-Regular.woff') format('woff'), url('https://raw.githubusercontent.com/tonsky/FiraCode/master/distr/ttf/FiraCode-Regular.ttf') format('truetype'); font-weight: normal; font-style: normal; }`); styleNode.appendChild(styleText); document.getElementsByTagName('head')[0].appendChild(styleNode);
-
Open VS Code
-
Open
settings.json
then add the following:"editor.fontFamily": "Fira Code", "editor.fontLigatures": true, "editor.fontWeight": "400" // normal
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+p",
"command": "type",
"args": {
"text": "=>"
},
"when": "textInputFocus"
},
{
"key": "ctrl+shift+j",
"command": "type",
"args": {
"text": "$this->"
},
"when": "textInputFocus"
},
{
"key": "ctrl+shift+k",
"command": "type",
"args": {
"text": "->"
},
"when": "textInputFocus"
},
{
"key": "ctrl+shift+l",
"command": "type",
"args": {
"text": "<?php"
},
"when": "textInputFocus"
},
{
"key": "shift+enter",
"command": "type",
"args": {
"text": "$"
},
"when": "textInputFocus"
},
{
"key": "shift+space",
"command": "type",
"args": {
"text": "_"
},
"when": "textInputFocus"
},
Listed below are recommended VS Code extensions for Web development. However, most of them are already included in .vscode/extensions.json