PHP Classes

PHP Framework Bootstrap 4 Template: Show application pages using Bootstrap templates

Recommend this page to a friend!
  Info   View files Example   View files View files (24)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 126 This week: 1All time: 9,407 This week: 560Up
Version License PHP version Categories
template-bootstrap4 1.0.0MIT/X Consortium ...5HTML, PHP 5, Libraries, Templates
Description 

Author

This package can show application pages using Bootstrap templates.

It provides an example application that uses the PHP MVC Project framework.

The package uses HTML templates using the BootStrap 4 library with PHP code embedded values inserted dynamically in the generated pages.

Picture of Aleksey
  Performance   Level  
Name: Aleksey <contact>
Classes: 3 packages by
Country: Russian Federation Russian Federation
Age: ???
All time rank: 331190 in Russian Federation Russian Federation
Week rank: 411 Up22 in Russian Federation Russian Federation Up
Innovation award
Innovation award
Nominee: 1x

Example

<?php
// use aoutoload (recommended)
require_once getcwd() . '/vendor/autoload.php';
// or include the required files
// require_once getcwd() . '/vendor/php-mvc-project/php-mvc/src/index.php';

use PhpMvc\AppBuilder;

// IMPORTANT: specify the root namespace of your application and check code
AppBuilder::useNamespace('RootNamespaceOfYourApp');

// you can change the root path of your application (usually not required)
// AppBuilder::useBasePath(getcwd());

// enable session usage
AppBuilder::useSession();

/*
// you can add any headers that will be sent in response to client requests:
AppBuilder::useHeaders(array(
    'X-Powerd-By' => 'PHP',
    'X-Author' => '%username%')
);
*/

/*
// by default all validators are included, you can disable unnecessary validators:
AppBuilder::useValidation(array(
    // checks the request parameters for dangerous combinations of characters, such as: <, # &
    // if you disable this validator, then requests will not be checked
    'crossSiteScripting' => false,

    // checks the name of the action so that it does not begin with the characters __
    // this check prohibits calling public constructors and other magic methods
    // for example: /home/__construct
    'actionName' => false,

    // checks the POST request token if the token was placed on the form
    // this allows to filter requests from stupid bots
    'antiForgeryToken' => false)
);
*/

// you can enable caching
// for example, FileCacheProvider
// you can use any cache provider or create your own with the interface PhpMvc\CacheProvider
// AppBuilder::useCache(new PhpMvc\FileCacheProvider());

// custom handlers
AppBuilder::useAppContext(function(PhpMvc\AppContext $appContext) {
   
/*
    // pre-init application handler
    $appContext->addPreInit(function(PhpMvc\ActionContext $actionContext) {
        // $httpContext = $actionContext->getHttpContext();
    });
    */

    /*
    // init application handler
    $appContext->addInit(function(PhpMvc\ActionContext $actionContext) {
    });
    */

    /*
    // init handler of the action context of the current request
    $appContext->addActionContextInit(function(PhpMvc\ActionContext $actionContext) {
    });
    */

    /*
    // pre-send output handler
    $appContext->addPreSend(function(PhpMvc\ActionContext $actionContext) {
        // $httpContext = $actionContext->getHttpContext();
    });
    */

    /*
    // partial output handler
    $appContext->addFlush(function(PhpMvc\ActionContext $actionContext, $eventArgs) {
    });
    */

    /*
    // end output handler
    $appContext->addEnd(function(PhpMvc\ActionContext $actionContext) {
    });
    */

    /*
    // application error handler
    $appContext->addErrorHandler(function(PhpMvc\ErrorHandlerEventArgs $errorHandlerEventArgs) use ($appContext) {
        // $errorHandlerEventArgs->setHandled(true);
        // $httpContext = $appContext->getConfig('httpContext');
    });
    */
});

// routes
AppBuilder::routes(function(PhpMvc\RouteProvider $routes) {
   
// the higher the rule in the list (the earlier the rule was added), the higher the priority in the search for a match

    // in templates you can use any valid characters in the URL

    // use curly braces to denote the elements of the route
    // each element must contain a name
    // for example:
    // {controller}/{action}
    // {action}/{controller}
    // {elementName_1}/{elementName_2}/{elementName_N}
    // get-{username=anonymous}/send-message/{text}

    // after the element name, you can specify a default value in the template:
    // {controller=home}

    // if the path element is optional, then the question (?) symbol is followed by the name:
    // {id?}

    // catch-to-all:
    // content/{*file}

    // ignore paths
   
$routes->ignore('favicon.ico');
   
$routes->ignore('content/{*file}');

   
// default route
   
$routes->add('default', '{controller=home}/{action=index}/{id?}');
});

// custom settings
// AppBuilder::set('key_1', 'value_1');
// AppBuilder::set('key_2', 'value_2');
// AppBuilder::set('key_N', 'value_N');
// to get the settings use:
// $value = AppBuilder::get('key_1');

// for experts: the default route provider is PhpMvc\DefaultRouteProvider
// you can make your own provider based on the PhpMvc\RouteProvider interface
// or use a solution from third parties
// AppBuilder::useRouter(new PhpMvc\DefaultRouteProvider());

// for experts: you can make and use your own PhpMvc\HttpContext implementation based on the PhpMvc\HttpContextBase class
// AppBuilder::useHttpContext(new PhpMvc\HttpContext());

// build app
AppBuilder::build();


Details

Bootstrap 4 Template

Template for initializing the PHP MVC Project application using Bootstrap v4.

The template includes a standard directory structure MVC, contains a samples of controllers and view files, and includes layout Bootstrap based.

Also, the template will include a filter for error handling.

Demo

Installation

git clone https://github.com/php-mvc-project/template-bootstrap4.git my-app
cd my-app
composer install

Requirements

  • PHP 7.x
  • Composer

License

The MIT License (MIT)

Copyright © 2018, @meet-aleksey


  Files folder image Files  
File Role Description
Files folder image.vscode (2 files)
Files folder imagecontent (1 file, 2 directories)
Files folder imagecontrollers (3 files)
Files folder imagefilters (2 files)
Files folder imagemodels (2 files)
Files folder imageviews (1 file, 3 directories)
Accessible without login Plain text file .htaccess Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  .vscode  
File Role Description
  Accessible without login Plain text file launch.json Data Auxiliary data
  Accessible without login Plain text file tasks.json Data Auxiliary data

  Files folder image Files  /  content  
File Role Description
Files folder imageimages (1 file)
Files folder imagestyles (1 file)
  Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  content  /  images  
File Role Description
  Accessible without login Image file php-mvc-logo.png Data Auxiliary data

  Files folder image Files  /  content  /  styles  
File Role Description
  Accessible without login Plain text file app.css Data Auxiliary data

  Files folder image Files  /  controllers  
File Role Description
  Plain text file AccountController.php Class Class source
  Plain text file HomeController.php Class Class source
  Plain text file README.md Class Class source

  Files folder image Files  /  filters  
File Role Description
  Plain text file HandleError.php Class Class source
  Plain text file README.md Class Class source

  Files folder image Files  /  models  
File Role Description
  Plain text file Login.php Class Class source
  Plain text file README.md Class Class source

  Files folder image Files  /  views  
File Role Description
Files folder imageaccount (1 file)
Files folder imagehome (3 files)
Files folder imageshared (3 files)
  Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  views  /  account  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files  /  views  /  home  
File Role Description
  Accessible without login Plain text file about.php Aux. Auxiliary script
  Accessible without login Plain text file contact.php Aux. Auxiliary script
  Accessible without login Plain text file index.php Aux. Auxiliary script

  Files folder image Files  /  views  /  shared  
File Role Description
  Accessible without login Plain text file error.php Aux. Auxiliary script
  Accessible without login Plain text file _layout.php Example Example script
  Accessible without login Plain text file _login.php Example Example script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:126
This week:1
All time:9,407
This week:560Up