including Gulp essential tasks
This project is a ready-to-use package to start a Bootstrap 4 project using a solid structure & efficient development tools such as Saas, Gulp, Altorouter, PHP Fast Cache, Twig.
It is based on a clean MVC workflow, and offers a basic HTML/JS/CSS structure with a sticky navbar, a sticky sidebar, a footer always at the bottom of the page.
It includes some Bootstrap 4 PHP Classes to build Bootstrap Navs and Sidebars. The generated elements are rendered with Twig Template Engine
It also uses smart optimization tools such as WebP generator, LoadJs and generates Critical CSS with GULP.
- Node.js installed for Gulp tasks
- PHP Server
-
Download the latest release. or Clone the repo:
git clone https://github.com/migliori/bootstrap-4-starter-project.git
-
Unzip the package content to the root of your project
-
Open command prompt, navigate to your project folder
-
run npm:
npm install
to install node_modules. -
run Composer:
composer install
to install PHP dependencies
Within the download you'll find the following directories and files:
bootstrap-4-starter-project/
├── .htaccess
├── composer.json
├── composer.lockjson
├── dropdown-page.php
├── gulpfile.js
├── home.php
├── index.php
├── LICENSE.md
├── nav-page.php
├── package-lock.json
├── package.json
├── README.md
├── webp_generator.php
├── conf/
│ ├── .htaccess
│ └── conf.php
├── assets/
│ ├── fonts/
│ ├── images/
│ ├── javascripts/
│ ├── sass/
│ └── stylesheets/
├── class/
│ ├── altorouter
│ ├── bootstrap
│ ├── common
│ └── lib
├── conf/
├── dist/
├── gulp/
│ ├── config.json
│ ├── critical.js
│ ├── images.js
│ ├── sass.js
│ └── scripts.js
├── i18n/
├── inc/
│── templates/
└── tmp/
-
All requests to non-existent files are rewrited to
index.php
using .htaccess -
index.php
uses Altorouter to match the request, then includes the main PHP page -
The main configuration file -
conf/conf.php
- defines global PHP constants for:- global URLs
- global paths
- environment (development/production)
- debug (false/true)
- icons
- db connection
- autoloader implementation for the php engine.
-
An additional configuration file -
conf/user-conf.php
- defines customizable PHP constants for:- PHP Cache duration
- default timezone
- language settings
- others
-
PHP Cache is used only in
production
environment -
environment & cache duration are defined in
conf/user-conf.php
-
Instructions available here: Gulp essential tasks
- sass
- scripts
- bootstrapjs (part of scripts)
- images
- critical (critical css for html & php files)
-
- Nav
- Navbar
- Sidebar
-
- Bootstrap CSS can be customized in
assets/sass/bootstrap.scss
(comment/uncomment to add/remove Bootstrap components) - Bootstrap Javascript can be customized in
gulp/scripts.js
=>bootstrapjs
(comment/uncomment to add/remove Bootstrap components)
- Bootstrap CSS can be customized in
-
-
Localhost is automagically detected in
conf/conf.php
.- On Localhost css and js files are served unminified and uncompiled.
-
Production server:
- CSS files are compiled into a single
all.min.css
with preload. - Javascript dependencies are minified and loaded with
LoadJs
asynchronously - definitely the best way to load JS dependencies.
- CSS files are compiled into a single
-
The main PHP pages are following the best practices for fast loading:
- Preload CSS
- Defer Javascript
- Google Webfonts Loader
These practices contribute to make the web faster and play nice with Critical CSS.
-
-
The critical CSS code is generated and saved in
[css-dir]/critical/[filename].min.css
where[css-dir]
is the directory defined inconfig.js
for your CSS files, and[filename]
is the basename of the PHP source file.GULP Critical generates your critical CSS, you have to copy/paste it into your pages.
-
We use WebP convert to serve WebP images - all's configured, it works on the fly.
We use SemVer for versioning. For the versions available, see the tags on this repository.
- Gilles Migliori - Initial work - Migliori
This project is licensed under the MIT License - see the LICENSE.md file for details