Skip to content

Instantly share code, notes, and snippets.

@danilobatistaqueiroz
Last active November 24, 2017 01:22
Show Gist options
  • Save danilobatistaqueiroz/8e878d04638ddf6133fcfb7c3f30b86a to your computer and use it in GitHub Desktop.
Save danilobatistaqueiroz/8e878d04638ddf6133fcfb7c3f30b86a to your computer and use it in GitHub Desktop.
Starting with slim micro framework

Starting with slim micro framework

A very simple example of a Slim application

there are many ways to start a new project using composer.

one simple way to begin with Slim using Composer is typing in a new folder:

composer require slim/slim

now create a folder named public

and after, create a file index.php inside public folder with the following content:

<?php
require 'vendor/autoload.php';

$app = new \Slim\App;

$app->get('/', function () { 
  echo "Hello, World!"; 
}); 

$app->run();

and after, run the command line at the root folder: php -S localhost:8080 -t public public/index.php

all calls to localhost:8080 will pass through index.php


Working with routes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment