/Slice/ A little slice of Laravel

Basic routing and templating, using Laravel's illuminate components.

Installation

To create a new App with Slice, just run the command below.

                
                    composer create-project -s dev cupoftea/slice "Your App Path"
                
            

Usage

Using Slice is a super simple. Just define your routes in routes/web.php or routes/api.php, and start creating your views in resources/views. Slice will take care of the rest.

routes/web.php
                    
                        <?php
                        
                        $router->view('/', 'home')->name('home');
                        $router->view('about', 'about')->name('about');
                    
                
resources/views/home.blade.php
                    
                        @extends('layouts.master')
                        
                        @section('content')
                            <div class="container">
                                <h1>Hello World</h1>
                                <p class="lead">Welcome to my app!</p>
                            </div>
                        @endsection
                    
                
resources/views/about.blade.php
                    
                        @extends('layouts.master')
                        
                        @section('content')
                            <div class="container">
                                <h1>About My App</h1>
                                <p class="lead">I made this all by myself!</p>
                            </div>
                        @endsection
                    
                
resources/views/layouts/master.blade.php
                    
                        <!DOCTYPE html>
                        <html lang="{{ str_replace('_', '-', app()->getLocale()) }}" id="Slice">
                        <head>
                            <meta charset="utf-8">
                            <meta name="viewport" content="width=device-width, initial-scale=1">
                            
                            <title>{{ config('app.name', 'My App') }}</title>
                            
                            <!-- Fonts -->
                            <link rel="dns-prefetch" href="https://fonts.gstatic.com">
                            <link href="https://fonts.googleapis.com/css?family=Lato:300,400,400i,700" rel="stylesheet">
                            
                            <!-- Styles -->
                            <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
                        </head>
                        <body class="route-{{ app('router')->currentRouteName() }}">
                            <div id="app">
                                <nav class="navbar navbar-expand-lg navbar-light bg-light">
                                    <a class="navbar-brand" href="/">My App</a>
                                    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
                                        <span class="navbar-toggler-icon"></span>
                                    </button>
                                    <div class="collapse navbar-collapse" id="navbarNav">
                                        <ul class="navbar-nav">
                                            <li class="nav-item {{ app('router')->currentRouteName() == 'home' ? 'active' : '' }}">
                                                <a class="nav-link" href="{{ route('home') }}">
                                                    Home
                                                    @if(app('router')->currentRouteName() == 'home')<span class="sr-only">(current)</span>@endif
                                                </a>
                                            </li>
                                            <li class="nav-item {{ app('router')->currentRouteName() == 'about' ? 'active' : '' }}">
                                                <a class="nav-link" href="{{ route('about') }}">
                                                    About
                                                    @if(app('router')->currentRouteName() == 'about')<span class="sr-only">(current)</span>@endif
                                                </a>
                                            </li>
                                        </ul>
                                    </div>
                                </nav>
                                @yield('content')
                            </div>
                        </body>
                        </html>
                    
                

Helpers

Slice has a bunch of useful helpers you'll probably recognise from Laravel. In addition, all helpers from illuminate/support are also available to you.