mhulse/slim-php-boiler

So I can get up-and-running with Slim quickly.

1.0.0 2016-11-27 23:12 UTC

This package is not auto-updated.

Last update: 2024-04-14 01:36:06 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-run composer install. You should never run composer update in production. If however you deploy a new composer.lock with new dependencies and/or versions (after having run composer update in dev) [you can] then run composer 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.

68747470733a2f2f6769746875622e676c6f62616c2e73736c2e666173746c792e6e65742f696d616765732f69636f6e732f656d6f6a692f6f63746f6361742e706e67