PHP Classes

Boot Help Demo: Hidden word and hidden number games with Bootstrap

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 161 All time: 8,954 This week: 455Up
Version License PHP version Categories
boot-help-demo 0.1.0MIT/X Consortium ...5.4PHP 5, Games
Description 

Author

This package implements the hidden word and hidden number games with Bootstrap.

It renders and processes the game on a Web page asking the players to enter the letters or numbers that have to be guessed.

It uses the Boot Help package to render the user interface using the Bootstrap library.

Picture of Jorge Cobis
  Performance   Level  
Name: Jorge Cobis <contact>
Classes: 3 packages by
Country: Venezuela Venezuela
Age: ???
All time rank: 12354 in Venezuela Venezuela
Week rank: 18 Up1 in Venezuela Venezuela Up
Innovation award
Innovation award
Nominee: 1x

Example

<?php
/*
 * BootHelpDemo
 *
 * (The MIT License)
 *
 * Copyright (c) 2015 Jorge Cobis <jcobis@gmail.com / http://twitter.com/cobisja>.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

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

use
BootHelpDemo\Game;
use
cobisja\BootHelp\BootHelp;


session_start();

$_SESSION = [];
$game_id = filter_input(INPUT_GET, 'game_id');

$_SESSION['selected_game'] = $game_klass = 'BootHelpDemo\\' . $game_id . 'Game';

!isset(
$_SESSION['started_game']) ? $_SESSION['started_game'] = true : null;
!isset(
$_SESSION['real_data']) ? $_SESSION['real_data'] = null : null;
!isset(
$_SESSION['hidden_data']) ? $_SESSION['hidden_data'] = null : null;
!isset(
$_SESSION['previous_data']) ? $_SESSION['previous_data'] = '' : null;
!isset(
$_SESSION['attempts']) ? $_SESSION['attempts'] = ['total'=>0, 'good'=>0] : null;

$game = new Game(new $game_klass($_SESSION['real_data'], $_SESSION['hidden_data']), $_SESSION['attempts'], $_SESSION['previous_data']);

$_SESSION['real_data'] = $game->get_real_data();
$_SESSION['hidden_data'] = $game->get_hidden_data();

echo
BootHelp::content_tag('div', $game->show_description(), ['id'=>'game-description', 'class'=>'row']);
echo
BootHelp::content_tag('div', $game->run(), ['id'=>'game', 'class'=>'row']);
echo
BootHelp::content_tag('div', '', ['id'=>'game-progress', 'class'=>'row']);


Details

BootHelpDemo

Demo application about [BootHelp] using.

About

This demo app is designed to show you how [BootHelp] classes can be used to easily generate HTML code formatted according to [Bootstrap] specifications without to write down a lot of complicated HTML code.

Two simple games has been implemented:

  • Guess the hidden word.
  • Guess the hidden number.

Both games show how to define and use the following [BootHelp] components:

  • [Alert box].
  • [Navbar].
  • [Modal].
  • [Button].
  • [Button group].
  • Dropdown.
  • [Icon].
  • [Progress bar].
  • [Panel].
  • [Panel row].
  • [Content tag].
  • [Link To].

The games are just an excuse to help you to get an idea about how you can use [BootHelp] classes in your own projects.

Check the source code and you'll see the amount of HTML code used is the minimun. No more boring HTML code!

Requirements

  • Any flavour of PHP 5.4+
  • [jQuery] 1.9
  • [Bootstrap] 3.3.4

Remember that [BootHelp] just generates HTML code acording Bootstrap specifications v3.3.4.

Getting started

Setting up the environment

[Composer] is the PHP's package manager and is the recommended way to get packages for your projects. It's also able to build automatically *autoloaders* if you wrote down your code using PSR-0 and/or PSR-4 standards, avoiding you headaches about everything related to loading classes.

  1. Install Composer:
        curl -s https://getcomposer.org/installer | php
    
  2. Get inside BootHelpDemo root folder and execute:
        php composer.phar install
        ```
    
    
  3. Copy the followings files into specified locations:

    cp path/to/bootstrap.min.css html/css cp path/to/bootstrap/fonts/* html/fonts cp path/to/bootstrap.min.js html/js cp path/to/jquery.min.js html/js ```

  4. Load in your browser root script index.php and enjoy!!!.

Author

[Jorge Cobis]

By the way, I'm from Bolivarian Republic of Venezuela :-D

Contributing

Feel free to contribute!!!. Welcome aboard!!!

Misc

Version history

0.1.0 (Friday, 1st May 2015)

  • Initial public release.

License

Copyright (c) 2015 Jorge Cobis (<jcobis@gmail.com>)

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

[boothelp]:https://github.com/cobisja/boothelp [bootstrap]:http://getbootstrap.com/ [bootstrap requirements]:http://getbootstrap.com/getting-started/ [jQuery]:http://jquery.com [Jorge Cobis]:mailto:jcobis@gmail.com [alert box]:https://github.com/cobisja/boothelp/blob/master/src/AlertBox.php [navbar]:https://github.com/cobisja/boothelp/blob/master/src/Navbar.php [modal]:https://github.com/cobisja/boothelp/blob/master/src/Modal.php [button]:https://github.com/cobisja/boothelp/blob/master/src/Button.php [button group]:https://github.com/cobisja/boothelp/blob/master/src/ButtonGroup.php [dropdown]:https://github.com/cobisja/boothelp/blob/master/src/Dropdown.php [icon]:https://github.com/cobisja/boothelp/blob/master/src/Icon.php [progress bar]:https://github.com/cobisja/boothelp/blob/master/src/ProgressBar.php [panel]:https://github.com/cobisja/boothelp/blob/master/src/Panel.php [panel row]:https://github.com/cobisja/boothelp/blob/master/src/PanelRow.php [content tag]:https://github.com/cobisja/boothelp/blob/master/src/Helpers/ContentTag.php [link to]:https://github.com/cobisja/boothelp/blob/master/src/Helpers/LinkTo.php


  Files folder image Files (18)  
File Role Description
Files folder imagehtml (2 files, 2 directories)
Files folder imagesrc (5 files, 1 directory)
Accessible without login Plain text file CHANGELOG.md Data Documentation
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file index.php Appl. Application script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (18)  /  html  
File Role Description
Files folder imagecss (1 file)
Files folder imagejs (1 file)
  Accessible without login Plain text file footer.html Data Auxiliary data
  Accessible without login Plain text file header.html Data Auxiliary data

  Files folder image Files (18)  /  html  /  css  
File Role Description
  Accessible without login Plain text file boothelpdemo.css Data Auxiliary data

  Files folder image Files (18)  /  html  /  js  
File Role Description
  Accessible without login Plain text file boothelp-demo.js Data Auxiliary data

  Files folder image Files (18)  /  src  
File Role Description
Files folder imagecore (4 files)
  Accessible without login Plain text file about.php Appl. Application script
  Accessible without login Plain text file demo_info.php Appl. Application script
  Accessible without login Plain text file navbar.php Appl. Application script
  Accessible without login Plain text file play_game.php Example Application script
  Accessible without login Plain text file process_user_input.php Appl. Application script

  Files folder image Files (18)  /  src  /  core  
File Role Description
  Plain text file Game.php Class Class source
  Plain text file GameInterface.php Class Class source
  Plain text file GuessNumberGame.php Class Class source
  Plain text file GuessWordGame.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:161
This week:0
All time:8,954
This week:455Up