Skip to content

Installation

Josh 'VaMoose' harington edited this page Feb 15, 2017 · 5 revisions

PHPStencil

Step 1 - Installation:

Step 1.1

Install Laravel framework. The following command will install the latest version of Laravel with the project name LaravelDefault.


composer create-project laravel/laravel LaravelDefault

Step 1.2

Download Zip from PHPStencilGit repo.

Step 2 - Configuration:

Step 2.1

Create a folder called "Packages" inside of the root of the Laravel project.

Step 2.2

Paste the folder from the Git repo (Step 1.2) inside the Packages folder.

Step 2.3

Inside the root Laravel project, open the composer.json file. In that file, look for:


"autoload" : {
    "psr-4": {
        ...

Inside of the psr-4 tag, load the following:


"EONConsulting\\PHPStencil\\": "Packages/PHPStencil/src"

Just as above, except in the components composer.json file:


"EONConsulting\\PHPStencil\\": "src/*"

Step 2.4 - Use as a global function instead of by namespace (Optional)

Under the psr-4 but still inside of the autoload if the array files does not exist, create it like this:


"files": [
    ...
]

And enter into it:


"Packages/PHPStencil/src/Http/helpers.php"

And again, in the components composer.json file:


"src/Http/helpers.php"

Step 3 - Registering the Service Provider

Step 3.1

Open up config/app.php. In the providers array, enter the following:


EONConsulting\PHPStencil\PHPStencilServiceProvider::class,

Step 3.2

In the same file, in the aliases array, enter:


'PHPStencil' => \EONConsulting\PHPStencil\src\Facades\PHPStencil::class,

Step 4 - Tsugi

To be able to use the tsugi, the APP_URL in your env file needs to be correct. So change it to the URL you are using for your testing environment.

Step 5 - The Finale

In the command line / terminal, enter the following command in the root of the Laravel project:


composer dump-autoload -o

Migrations

We have included a dummy_table in the database for testing purposes. To have access to the migrations, you will need to perform the following commands:


php artisan vendor:publish
php artisan migrate

Testing

Let's see this in action. Go to routes/web.php and where it says return view('welcome'); replace that with


echo PHPStencil::output(); 
// or
echo phpstencil()->output(); // if you did step 2.4
 

To test this out, go to the URL for this Laravel site.

You should now see the result "Hello World" being printed out to the screen.