Skip to content
Patrick Garske edited this page Jan 29, 2019 · 9 revisions

Getting Started

Composer

To install BootstraPHP via Composer, use the following commands:

composer require tuxnull/bootstraphp - Installs latest release

composer require tuxnull/bootstraphp:dev-master - Installs latest in-dev build (potentially unstable)

BootstraPHP uses composer's autoload feature. To use BootstraPHP functions in your PHP script, simply include the composer autoload file:

require __DIR__ . '/vendor/autoload.php';

To check if your installation was successfull, navigate to your PHP web-app and view source. You should see something like this at the top of your page source:

<!-- BootstraPHP initialized! https://github.com/tuxnull/BootstraPHP --><meta name='bootstraPHP' content='https://github.com/tuxnull/BootstraPHP'>

If you dont get this message, try installing BootstraPHP manually with the method below.

Manual Installation

To start using BootstraPHP, download the bootstrap.php file to the same folder where your PHP web-app is located. Then simply include the bootstrap.php file with the following statement:

include ("bootstrap.php");

The bootstrap.php script currently doesn't automatically check for updates, so make sure you check this page every week or so.

Using BootstraPHP

To use any BootstraPHP method, you will first have to run init_meta() for META tag initialization (Mobile Friendly Resizing), init_stylesheet() for including the Bootstrap CDN CSS file and init_js() for including the jQuery and Bootstrap JavaScript files. Don't forget to add echo in front of these functions as they dont echo the output but return it (since Version 0.0.3).

Starter Template

<?PHP
require __DIR__ . "/vendor/autoload.php";
?>

<!doctype html>
<html>
<head>
<?PHP
echo init_meta();
echo init_stylesheet();
echo page_title("BootstraPHP Starter Template");
?>
</head>
<body>
It works!
</body>
<?PHP
echo init_js();
?>
</html>