mhulse / slim-php-boiler
So I can get up-and-running with Slim quickly.
Requires
- php: >=5.5.0
- illuminate/database: ^5.3
- monolog/monolog: ^1.17
- respect/validation: ^1.1
- slim/csrf: ^0.7.0
- slim/flash: ^0.2.0
- slim/slim: ^3.1
- slim/twig-view: ^2.1
This package is not auto-updated.
Last update: 2025-04-13 06:35:37 UTC
README
So I can get up-and-running with Slim quickly.
The code in this repository is heavily based on, and inspired by, Authentication with Slim 3 by @codecourse.
Development process
Suggested development steps follow. Be sure to fully read instructions before modifying code.
Project directory
Create a git repository:
$ cd dev/ $ git init repo-name && cd repo-name
Optionally, install my boilerplate dotfiles:
$ curl -#L https://github.com/mhulse/gh-boiler/tarball/master | tar -xzv --strip-components 1 --include=*/{.editorconfig,.gitattributes,.gitignore} --exclude=*/**/*
At a bare minimum for dotfiles, you should create a .gitignore
with these lines:
composer.phar
vendor/
config.php
Install Composer
Install Composer:
$ curl -s http://getcomposer.org/installer | php
Official Composer installation instructions found here.
Get this code
Download the code from this repo using composer:
$ php composer.phar create-project mhulse/slim-php-boiler temp
Or, using bash
and curl
:
$ mkdir temp && cd temp && bash <(curl -sL https://git.io/v1ITb) && cd -
Move the downloaded files from temp/
into the repository’s root:
$ mv temp/* . && rm -rf temp/
Install application dependencies
Get the composer-installable code:
$ php composer.phar install
If/when needed, update Composer dependencies using:
$ php composer.phar update
WARNING: You should never run composer update
on the production machine!
[after] deploy[ing] your updated
composer.lock
, [you should] then re-runcomposer install
. You should never runcomposer update
in production. If however you deploy a newcomposer.lock
with new dependencies and/or versions (after having runcomposer update
in dev) [you can] then runcomposer install
[and] Composer will update and install your new dependencies [onto the production machine’s deployment].
– “composer update” vs “composer install”
Database
In order for this app to work, create a database named slim-php-boiler
with UTF-8 Unicode
for the encoding and utf8_general_ci
for the collation.
Create a users
table:
DROP TABLE IF EXISTS `users`; CREATE TABLE `users` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(255) DEFAULT NULL, `email` varchar(255) NOT NULL DEFAULT '', `password` varchar(255) NOT NULL DEFAULT '', `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
In the root of the repo, crate a config.php
(see config-sample.php
):
<?php define('DB_HOST', '127.0.0.1'); define('DB_NAME', 'slim-php-boiler'); define('DB_USER', 'root'); define('DB_PASSWORD', ''); define('DB_PORT', 3306);
Run development server
$ php composer.phar start
… and visit http://0.0.0.0:8080/.
What else?
For more information, check out this repo’s Wiki.
LEGAL
Copyright © 2016-2017 Michael Hulse.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.