Installation can be done using Composer/Packagist. Simply enter the following commands in your shell and all of the Stoic components will be installed for a website to be built:
composer require stoic/web
vendor/bin/stoic-create
Stoic will have created the following folder structure for your project:
~/inc/classes/
~/inc/repositories/
~/inc/utilities/
~/index.php
~/siteSettings.json
This folder should contain any class definitions. Any files with the extension .cls.php
in this folder will be automatically included when Stoic is loaded.
For more information on classes, click here.
This folder should contain any repository classes, which normally provide methods for returning data in the form of classes.
Any files with the extension .rpo.php
in this folder will be automatically included when Stoic is loaded.
For more information on repositories, click here.
This folder should contain any files that provide utility functionality for your site.
Any files with the extension .utl.php
in this folder will be automatically included when Stoic is loaded.
For more information on utility files, click here.
This file is a quick example of how Stoic can be loaded and used as an entry-point for a website.
For more information on entry-points and Stoic, click here.
The settings file siteSettings.json
contains the default configuration values for the site.
The settings file is setup using the Config Migration library.
Replace the contents of the index.php file:
<?php
// Pull in all files via Composer autoload
require("vendor/autoload.php");
// Grab the Stoic class for use, setting the 'root' directory to the current directory
use Stoic\Web\Stoic;
$stoic = Stoic::getInstance("./");
// Retrieve the ParameterHelper for $_GET from the request
$get = $stoic->getRequest()->getGet();
// Retrieve the ParameterHelper for $_SERVER from the request
$server = $stoic->getRequest()->getServer();
// Output some random information
echo("Hello, World!<br />");
echo("I am {$server->get('REMOTE_ADDR')}");
// If we have a magical $_GET variable, show it
if ($get->has('magic_var')) {
echo("<br />Secret Message: {$get->get('magic_var')}");
}
Which will produce something similar to:
Hello, World!
I am ::1
If you visit the page and add ?magic_var=test
, the following will be produced:
Hello, World!
I am ::1
Secret Message: test
Continue to read general information about Stoic:PHP, or visit the Table of Contents.