https://github.com/markusfisch/phapp
A simple but scalable web application framework for PHP
https://github.com/markusfisch/phapp
php-framework
Last synced: 4 months ago
JSON representation
A simple but scalable web application framework for PHP
- Host: GitHub
- URL: https://github.com/markusfisch/phapp
- Owner: markusfisch
- License: unlicense
- Created: 2013-03-08T21:25:01.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2019-10-19T17:54:52.000Z (almost 6 years ago)
- Last Synced: 2023-03-11T13:38:07.095Z (over 2 years ago)
- Topics: php-framework
- Language: PHP
- Size: 11.7 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Phapp
=====A simple but scalable object-oriented web application framework.
Hello World
-----------A simple example:
process( 'Hello' );
Find this and more complex examples in the
[samples branch](https://github.com/markusfisch/Phapp/tree/samples).How it works
------------The idea is to define a set of view objects that get processed by the main
application object.Every view object inherits from PhappView which has two main methods you
should overwrite. The first is request():public function request()
{
if( !$_REQUEST['order_number'] )
return 'Home';return null;
}The purpose of this method is to handle the request and, if required, return
a name of another view that should take over.The first view that returns _null_ will get its response() method called to
respond to the request:public function response()
{
return 'Hello
';
}Here's a little graph that shows how everything works together:
+----------------------------+
| Name of a PhappView object | <-------------------------+
+----------------------------+ |
| |
| |
+-- Phapp ------|-------+ |
| | | |
| V | |
| +------------------------+ +-- PhappView ---------+ |
| | Construct object | ------> | | |
| +------------------------+ | Object derived | |
| | | | from PhappView | |
| V | | | |
| +------------------------+ +-- request() ---------+ |
| | Call request() on | | | |
| | that object | ------> | Determine if | |
| +------------------------+ | this object | |
| | | can handle | |
| +------------------------+ yes? | this request | no? |
| | request() returned | <------ | | -----+
| | null | +-- response() --------+
| | so call response() | ------> | |
| | to get the output | <------ | Generate output for |
| +------------------------+ html | this request |
| | | | |
+---------------|-------+ +----------------------+
|
V
+----------+
| Web page |
+----------+Phapp is very minimal and very small.
Just have a look at Phapp.php to fully understand its concept.Subclass to extend
------------------Subclass Phapp and PhappView to add methods for data base access,
internationalization and stuff like that.It's a good idea to set up a base view which contains common methods
and derive your views from that.PDO support
-----------If you're using [PDO](http://php.net/manual/en/book.pdo.php)'s,
you may inherit your views from PhappPDOView and call query() like this:if( ($result = $this->query(
"SELECT
first,
last
FROM members
WHERE last_login = ?
ORDER BY last",
$lastLogin )) )
{
while( ($row = $result->fetch()) )
{
$contents .= "
}
}
Stay up to date
---------------
It's probably best to add Phapp as submodule or
[subtree](https://blogs.atlassian.com/2013/05/alternatives-to-git-submodule-git-subtree/)
to your project's repository to be able to update fast and easily.