Download the PHP package frostybee/slim-template without Composer
On this page you can find all versions of the php package frostybee/slim-template. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download frostybee/slim-template
More information about frostybee/slim-template
Files in frostybee/slim-template
Package slim-template
Short Description A Slim framework skeleton for implementing REST-based Web services.
License MIT
Homepage https://github.com/frostybee/slim-template
Informations about the package slim-template
- Starter Template
- How Do I Use/Deploy this Template?
- Option 1: Using Composer (Recommended)
- Option 2: Using Docker (macOS/Linux/Windows)
- Option 3: Manual Installation
- Option 4: Using Nginx (Native Server)
- How Do I Configure My Database Connection?
- How do I Use Composer with Wampoon?
- On Using Environment Variables
- Useful VS Code Keybindings
Starter Template
This repository contains an application skeleton for creating REST-based Web services using the latest version of the Slim micro framework.
How Do I Use/Deploy this Template?
Option 1: Using Composer (Recommended)
- Open a terminal in your web server's document root (i.e.,
htdocs). -
Run the following command:
Replace
[project-name]with your project name (e.g.,worldcup-api). - Open your
[project-name]-apifolder in VS Code. - Adjust your database credentials in
config/env.php(see below).
Option 2: Using Docker (macOS/Linux/Windows)
Docker allows you to run the application in containers without installing PHP, Apache, or MariaDB locally. This works on macOS, Linux, and Windows.
Prerequisites:
- Install Docker Desktop
- Install Git
Quick Start:
-
Clone the repository (since Composer requires PHP, which you may not have installed):
Replace
[project-name]with your project name (e.g.,worldcup-api). -
Navigate to the project folder:
-
Remove the
.gitfolder to start fresh with your own repository: -
Start all containers by executing the following command:
Note: Use
docker-compose up -d --buildto rebuild images after modifying the Dockerfile or related configurations. - Access the application:
- App: http://localhost:8080
- phpMyAdmin: http://localhost:8081
Configuring the Database:
The default database name is slim_app. To use a different database name:
-
Update
docker-compose.yml: -
Update
config/env.docker.php: - Rebuild containers:
docker-compose up -d --build
Importing Database Schema:
To automatically import a database schema when the container starts:
- Place your
.sqlfile(s) in thedocker/init-db/folder - Start the containers:
docker-compose up -d
The SQL files will be executed automatically on first container creation. If you have multiple files, they run in alphabetical order (e.g., 01-schema.sql, 02-data.sql).
To re-import the schema, remove the database volume and restart:
| Database Credentials (for phpMyAdmin): | Username | Password |
|---|---|---|
| root | secret | |
| slim_user | slim_pass |
Common Commands:
| Action | Command |
|---|---|
| Start containers | docker-compose up -d |
| Stop containers | docker-compose down |
| View app logs | docker-compose logs -f app |
| Delete database | docker-compose down -v |
| Rebuild containers | docker-compose up -d --build |
Working with Multiple Projects:
If you run one project at a time, no configuration changes are needed. Simply stop one project before starting another:
If you need to run multiple projects simultaneously, change the port numbers in docker-compose.yml to avoid conflicts:
Option 3: Manual Installation
- Download this repository as a
.zipfile. - Extract the downloaded
slim-template-main.zipfile locally. - Copy the
slim-template-mainfolder into your web server's document root (i.e.,htdocs). - Rename the
slim-template-mainfolder to[project_name]-api(for example,worldcup-api). - Open your
[project_name]-apifolder in VS Code. - Install the project dependencies by running composer. If you are using Wampoon, open a terminal window in VS Code (hit ) then run
.\composer.bat update- If you are not using Wampoon to develop your app, just run composer from the command line.
- In the
configfolder, make a copy ofenv.example.phpand rename it toenv.php. - Adjust your database credentials (see below).
** You can always clone this repository. However, if you do, you need to remove the **hidden directory before you copy this template over to
Option 4: Using Nginx (Native Server)
If you're running Nginx directly on your server (not through Docker), configuration files are provided in the nginx/ directory.
Quick Start:
- Deploy your application to your server
- Copy
nginx/slim-template.confto/etc/nginx/sites-available/your-project-name - Edit the configuration file to match your setup (domain, paths, PHP-FPM socket)
-
Enable the site:
- Test and reload:
Important Notes:
- Set document root to the
public/directory (not the project root) - Nginx doesn't use
.htaccessfiles - all configuration is in the server config - You need PHP-FPM installed and running
For detailed instructions, see nginx/README.md.
How Do I Configure My Database Connection?
Follow the outlined instructions in config/env.example.php
- Change the value of the
databasevariable 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.
How do I Use Composer with Wampoon?
To install or update your project dependencies deployed on Wampoon, use the composer.bat script as follows:
| Action | Command | Description |
|---|---|---|
| Install dependencies | .\composer.bat install |
Installs packages listed in composer.json and creates the vendor directory. |
| Update dependencies | .\composer.bat update |
Refreshes all packages to the latest versions allowed by composer.json. |
| Add a package | .\composer.bat require [package] |
Installs a new package and adds it to composer.json. |
| Regenerate autoloader | .\composer.bat dump-autoload -o |
Rebuilds the optimized autoloader after adding or removing classes. |
On Using Environment Variables
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 Alternatively, you can visit the following link: Google env search
Instead, follow the instructions that are detailed in config/env.example.php
Useful VS Code Keybindings
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
All versions of slim-template with dependencies
ext-pdo Version *
ext-json Version *
slim/slim Version ^4.15
guzzlehttp/guzzle Version ^7.10
php-di/php-di Version ^7.1
firebase/php-jwt Version ^7.0
fig/http-message-util Version ^1.1
monolog/monolog Version ^3.10
nyholm/psr7 Version ^1.8
nyholm/psr7-server Version ^1.1