Skip to content

Fork of Happy Puppy. Happy Puppy is a nano web framework for PHP, forked from Nice Dog

Notifications You must be signed in to change notification settings

kolen/happypuppy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

Happy Puppy

Happy Puppy is a nano web framework for PHP. It is a fork of the Nice Dog project.

Happy Puppy lets you create pretty URLs loosely based on MVC. You create controllers with actions, and your URLs by default take the form of http://host/controller/action

So to handle the URL http://host/person/edit/Katie. You would write:

class person extends C
{
  function edit($name)
  {
    // do something here
  }
}

Easy! Of course you can also make more complex routes too.

After your controller's action has run, it will look for a template, by default in /views/person/edit.php to render the webpage.

That's the gist of it. It can do a lot more too. If you want to see it in action, you can view the samples at http://happypuppy.nfshost.com.
Quickstarts

Happy Puppy is a one file framework. You can either download HappyPuppy.php and build your system around it, or download the Samples and see Happy Puppy in use.
Quickstart with Samples

The Samples package includes examples of Happy Puppy in use and its documentation. You can either install it on your server, or see it in action at http://happypuppy.nfshost.com. The samples package contains lots of helper code which is not part of the Happy Puppy project. Any of this can be ripped out. The framework is only one file and all you really need is HappyPuppy.php. If you don't like all the filler in the Samples you can jump to the Bare Bones Quickstart below

   1. Download the Happy Puppy package at github
   2. Copy the files from the Samples directory to you webroot (/var/www/htdocs or wherever). (Note: the samples directory has a copy of HappyPuppy.php, so you can disregard the copy of HappyPuppy.php outside of the Samples directory)
   3. Point your browser at your webroot. Look at the examples and follow along in the code.

Quickstart Bare Bones - Getting started with only HappyPuppy.php

This options is for those who don't like reading directions

   1. Download the Happy Puppy package at github
   2. Copy the HappyPuppy.php file to any place on your web server
   3.

      Create a files index.php on your web server, preferebly in your webroot. Fill it with the following:

      <?php
      define('DOCROOT', getcwd().DIRECTORY_SEPARATOR);
      require 'path/to/HappyPuppy.php';
      run();
      ?>

      You can optionally add other things to this file: Session Start, loading common libraries, defining routes
   4.

      Make a directory called controllers, create a file hello.php there, add the following lines:

      class hello extends C
      {
        public function world(){
          echo "Hello World";
          $this->rendered = true;
        }
      }

   5.

      If you want pretty URLs, create a file .htaccess in your webroot with the following code

<IfModule mod_rewrite.c>
  RewriteEngine On 
  RewriteCond %{DOCUMENT_ROOT}/public%{REQUEST_URI} -f
  RewriteRule !(^index\.php|^public/) /public%{REQUEST_URI} [L]
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>

   6. navigate to http://host/hello/world

To see more complex examples, look at the samples
Why Fork?

I wanted to expand the functionality of Nice Dog. Some of the features are drawn from other frameworks. It's still a small framework, but not as small as Nice Dog is.

These are only the major features now present in Nice Dog

    * "Magic" Routes - The default route is /controller/action. You don't need to specify these in your routes file. You just create your controller with actions and you're done
    * Partials - You can render pages in pages (Yo dawg). Useful for not repeating yourself (use the same form to create or edit something)
    * Filters - Run a method before all your actions in a controller. Useful for authentication

Because it's a fork, it's been renamed

The MIT License

Copyright (c) 2007 Tiago Bastos 2009 Dave Roberts

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.

Originally The MIT License


About

Fork of Happy Puppy. Happy Puppy is a nano web framework for PHP, forked from Nice Dog

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • PHP 100.0%