Difference between revisions of "Slib"

From ProgClub
Jump to: navigation, search
(Mobile Casino Games - Portion One)
 
(58 intermediate revisions by the same user not shown)
Line 1: Line 1:
The Top i phone Apps - What'utes the Secret of Their Success?  
+
Slib is the ProgClub PHP framework software. That's the software that provides a framework for your PHP applications. For other projects see [[projects]].
 +
 
 +
== Project status ==
 +
 
 +
Version 0.1 has been released and it's being used.
 +
 
 +
Version 0.2 is under way and isn't ready for release yet. There's stuff [[Slib#TODO|TODO]].
 +
 
 +
== Contributors ==
 +
 
 +
Members who have contributed to this project. Newest on top.
 +
 
 +
* [[User:John|John Elliot V]]
 +
 
 +
All contributors have agreed to the terms of the [[ProgClub:Copyrights#ProgClub_projects|Contributor License Agreement]]. This excludes any upstream contributors who tend to have different administrative frameworks.
 +
 
 +
== Copyright ==
 +
 
 +
Copyright 2011-2014, [[Slib#Contributors|Contributors]]. Licensed under [https://www.apache.org/licenses/LICENSE-2.0 APACHE 2.0].
 +
 
 +
=== Libraries ===
 +
 
 +
The Slib software uses the following libraries:
 +
 
 +
* [https://github.com/browscap browscap]: [https://github.com/browscap/browscap/blob/master/LICENSE MIT License]
 +
* [https://www.maxmind.com/en/opensource MaxMind GeoIP]: You need a [https://www.maxmind.com/en/sitelicense GeoIP Site License] to use this software. See the [https://www.maxmind.com/en/faq FAQ]
 +
* Inflector: [https://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License]
 +
* [https://github.com/rchouinard/phpass PHPass]: [https://github.com/rchouinard/phpass/blob/master/LICENSE MIT License]
 +
* [http://getbootstrap.com/ Twitter Bootstrap]: [http://getbootstrap.com/getting-started/#license-faqs MIT License]
 +
* [https://jquery.org/ jQuery]: [https://jquery.org/license/ MIT License]
 +
* [http://jqueryui.com/ jQuery UI]: [https://jquery.org/license/ MIT License]
 +
* [http://jqueryvalidation.org/ jQuery Validation]: MIT License
 +
* [http://nicedit.com/ NicEdit]: [http://nicedit.com/license.php MIT License]
 +
* [https://github.com/twitter/typeahead.js/ typeahead.js]: MIT License
 +
* [https://github.com/aFarkas/html5shiv html5shiv]: [https://github.com/aFarkas/html5shiv/blob/master/MIT%20and%20GPL2%20licenses.md MIT and GPL2 licenses]
 +
 
 +
== Source code ==
 +
 
 +
The repository can be browsed online:
 +
 
 +
https://www.progclub.org/pcrepo/slib/branches
 +
 
 +
The code for slib is publicly available from svn:
 +
 
 +
https://www.progclub.org/svn/pcrepo/slib/tags/latest
 +
 
 +
Or privately available for read-write access:
 +
 
 +
https://www.progclub.org/svn/pcrepo/slib/branches
 +
 
 +
== Links ==
 +
 
 +
No links at this time.
 +
 
 +
== Functional specification ==
 +
 
 +
The software provides a web-framework/toolkit for PHP applications.
 +
 
 +
=== A new approach to dependency injection ===
 +
 
 +
The slib framework has a new approach to dependency injection. If you want to provide a mock/instrumented instance of any of the framework classes all you have to do is define the ClassName that you want to inherit from the SlibClassName. Your ClassName file will automatically be instantiated by the factory method that Creates/Loads your implementation. The way this works is that slib registers a [https://www.progclub.org/pcrepo/slib/trunk/src/mock-loader.php?view=markup mock-loader] that will generate a concrete type if no concrete type is defined and the base implementation operates on the concrete type.
 +
 
 +
=== Database interface ===
 +
 
 +
There is a [https://www.progclub.org/pcrepo/slib/trunk/src/db/SlibDatabase.php?view=markup Database] interface. Has support for [https://www.progclub.org/pcrepo/slib/trunk/src/db/DataSort.php?view=markup DataSort] sorting and [https://www.progclub.org/pcrepo/slib/trunk/src/db/DataPage.php?view=markup DataPage] pagination. There is no filtering support yet.
 +
 
 +
=== Database schema management ===
 +
 
 +
There is a [https://www.progclub.org/pcrepo/slib/trunk/src/db/SlibDatabaseUpgrader.php?view=markup DatabaseUpgrader] that handles database schema migrations. There was some talk of factoring the SQL out into .sql files, but I think this format is easier to maintain/reference as all the table definitions are right there in the source.
 +
 
 +
=== Asset management ===
 +
 
 +
There is a [https://www.progclub.org/pcrepo/slib/trunk/src/class/SlibResourceManager.php?view=markup ResourceManager] and a [https://www.progclub.org/pcrepo/slib/trunk/bin/compile.php?view=markup compiler]. The compiler bundles CSS and JavaScript, the ResourceManager handles requests for assets. Note: the compiler automatically generates .gz files for all assets so the ResourceManager can return them.
 +
 
 +
Support for graphics, style, scripts, and caching is provided by the ResourceManager.
 +
 
 +
=== Settings management ===
 +
 
 +
There is a [https://www.progclub.org/pcrepo/slib/trunk/src/class/SlibSettings.php?view=markup Settings] manager. It provides a layered approach to user settings. First we try to get a setting from the [https://www.progclub.org/pcrepo/slib/trunk/src/orm/SlibSessionSettings.php?view=markup Session], then the [https://www.progclub.org/pcrepo/slib/trunk/src/orm/SlibUserSettings.php?view=markup User] otherwise global default.
 +
 
 +
=== Session management ===
 +
 
 +
User sessions are managed by the [https://www.progclub.org/pcrepo/slib/trunk/src/orm/SlibSession.php?view=markup Session] component. Supports user login.
 +
 
 +
=== Authorisation management ===
 +
 
 +
There is an [https://www.progclub.org/pcrepo/slib/trunk/src/class/SlibAuth.php?view=markup Auth] component that defines authorisations for actions.
 +
 
 +
=== Role-based security ===
 +
 
 +
There is first-class support for [https://www.progclub.org/pcrepo/slib/trunk/src/orm/SlibUser.php?view=markup User] and [https://www.progclub.org/pcrepo/slib/trunk/src/orm/SlibRole.php?view=markup Role] facilitating role-based security.
 +
 
 +
=== URI/URL management ===
 +
 
 +
The SlibUri class and its associates provide an interface for reading and manipulating URIs. The following diagram illustrates the six types of URI supported and the component pieces:
 +
 
 +
[[File:SlibUriHierarchy-1.png]]
 +
 
 +
The software has been specifically designed to cater to specialised URI handling, such as seen with SlibMailtoUri which extends SlibUri with 'mailto' specific API such as get_mail_user(), get_mail_domain(), get_mail_subject(), etc., etc. At this time the only specialised URI is for mailto links, all other schemes are handled with URI types 1 to 5, most of them being a 4.
 +
 
 +
For a list of all documented URI schemes see [http://en.wikipedia.org/wiki/URI_scheme URI scheme] at Wikipedia. There is a [https://www.progclub.org/pcrepo/slib/trunk/etc/uri-gen.php?view=markup code generator] which generates the strong-typed URIs based on documented schemes. The idea is that the design caters for URIs to be scheme specific, but the design doesn't need to be done immediately. Presently the only real URI support is for schemes: http, https, file and mailto, the rest are generic for the time being.
 +
 
 +
Note: because of the decision to use 'strong-typed' classes on the API it is possible to do something odd. For example I could create a SlibHttpUri using ::Parse(...) and then on that URI change the scheme to 'mailto', I will then have a SlibHttpUri that reports its scheme as 'mailto', not 'http'. It's not a great design, but hey, it works if you don't push it and importantly: it's done!
 +
 
 +
Here's an example of using SlibUri for getting URL components:
 +
 
 +
$uri = SlibUri::Parse( "https://www.progclub.org/wiki/Main_Page", '/wiki' );
 +
$this->assertSame( 'https', $uri->get_scheme() );
 +
$this->assertSame( 'www.progclub.org', $uri->get_host()->to_string() );
 +
$this->assertSame( '/wiki', $uri->get_base() );
 +
$this->assertSame( '/Main_Page', $uri->get_path()->to_string();
 
   
 
   
Earlier this year, Apple released its list of top mobile phone apps at the 1 billion download mark. Downloads just hit two billion, making Apple'ersus "All-Time" Top Apps content label even sillier than it had been at the time -- but that aside, it's a very interesting list and there are a wide range of good lessons to always be learned from it.
+
$uri = SlibUri::Parse( "mailto:jj5@progclub.org?subject=test" );
 
   
 
   
We know that developers of some top apps have earned coming from $350,000 (Pocket God) to $800,000 (iShoot). Some have most probably earned a lot more. It's difficult to estimate income even if the number of downloads is known, because app pricing bounces close to a lot. Koi Pond provides been downloaded about 900,000 times and Enigmo over 800,000. Even at, say, a dollar a time, that'utes very good money.
+
$this->assertSame( 'jj5', $uri->get_mail_user() );
 +
$this->assertSame( 'progclub.org', $uri->get_mail_domain()->to_string() );
 +
$this->assertSame( 'test', $uri->get_mail_subject() );
 
   
 
   
Exactly how to get usage of this giant cash cow? Below are great tips, based on our review of Apple's twenty top paid apps:
+
$uri = SlibUri::Parse( "https://www.progclub.org/pcwiki/index.php?title=Main_Page&action=edit" );
 
   
 
   
Get in early
+
$this->assertSame( '/pcwiki/index.php', $uri->get_path()->to_string() );
 +
$this->assertSame( 'pcwiki', $uri->get( 1 ) );
 +
$this->assertSame( 'index.php', $uri->get( 2 ) );
 +
$this->assertSame( 'index.php', $uri->get_filename() );
 +
$this->assertSame( 'php', $uri->get_extension() );
 +
$this->assertSame( 'Main_Page', $uri->get( 'title' ) );
 +
$this->assertSame( 'edit', $uri->get( 'action' ) );
 +
 
 +
And here's an example of using SlibUri to build URLs:
 +
 
 +
$uri = SlibUri::Parse( "https://www.progclub.org/wiki/Main_Page", '/wiki' );
 
   
 
   
The iPhone 3G became available in July 2008. Almost half in the top apps had been released by August. The remaining were just about all out of the finish of 2008, except one which arrived on the scene in January 2009.
+
$uri = $uri->to_builder();
 
   
 
   
Timing is truly everything. Of course, some on this will be just some sort of physical reality -- if you sell 5,000 apps per day for 100 times, that'ersus five hundred,000 sales; if you only have 5 times, you can only get 25,000. But there'utes far more to it than that. There are only so many apps now (over 50,000) that it'utes very difficult to always be seen. Apps that arrived early, and earned traction, had a huge advantage over opponents, knowning that kind of edge is actually often maintained lengthy-term.
+
$uri->set( 'q', 'testing' );
 
   
 
   
Entertain the masses
+
$this->assertSame( "https://www.progclub.org/wiki/Main_Page?q=testing", strval( $uri ) );
 
   
 
   
If you'd like to save the planet, enlighten humanity or improve people's health, you'll get your reward in heaven, but you won'capital t have a winning i phone app. Every single 1 of the top paid apps is a toy of some kind. Fourteen are in the Games category, 4 Enjoyment and only two Music.
+
$uri->set( 'a', array( 1, 2, 3 ) );
 
   
 
   
Interestingly, this unique entertainment is generally not mindless. Most of the games are complex, requiring skill and amount, and a significant few have many permutations or constant updates (Pocket God). Complex games include Bank account God, Fieldrunners, Texas Maintain'em Texas hold'em and Monopoly. The less complicated games, like the memory matching online game Bejeweled a couple of or the skateboard app Touchgrind, still require skill and awareness.
+
$this->assertSame( "https://www.progclub.org/wiki/Main_Page?q=testing&a=1&a=2&a=3", strval( $uri ) );
 
   
 
   
Only a few, like Koi Pond, require little mental effort, but even this kind of a single provides many alternatives and constant movement. Absolutely almost all the apps have great graphics and plenty of movement.
+
$uri->clear( 'q' );
 +
$uri->clear( 'a' );
 
   
 
   
There were only two completely silly and pointless apps, namely the simulated alcohol app, iBeer, and the self-explanatory iFart Mobile.
+
// set the 4th path part:
 +
$uri->set( 4, 'test' );
 
   
 
   
There'utes a surprise in every single package
+
  $this->assertSame( "https://www.progclub.org/wiki/Main_Page//test", strval( $uri ) );
   
+
 
Ocarina, the early flute simulation, is actually a real surprise. Who would have thought a great obscure musical instrument would have ranked so high? The app developers are just when interesting -- a high-flying crowd of musicians and computer scientists from even like Stanford and Princeton. Could it be that there will be still a place for real leading and innovation on the Internet? Happy thought.  
+
=== TODO ===
+
 
Develop for the device
+
* Support for Min/Max defaults and specific validation
+
* TableView->name for use in sort/page/etc slugs (defaults to 'defalut')
Using the accelerometer seems to increase a good app'utes probabilities of success. A lot of the top paid apps are accelerometer-intensive, or use other novel or unique i phone features.  
+
* TableView->read_{selected,searched}_columns and ensure they are valid.
+
** If they are not valid remove the offending parameter and redirect
The message right here will be that successful app developers take advantage from the device's novel or special functionality. The iphone 4g will be mobile, it seems to have a touchscreen, it has an accelerometer. Develop for the device! Apps that work like though that they're on a regular desktop computer are probable to become significantly less successful.
+
* Joins omitted by selected columns
+
* Per entity database references (remove dependency on db singleton)
Have the right background
+
* Partition management
+
* DB Aggregator
It really helps to be a great experienced software program developer, ideally with a background in Internet games. The majority of the companies and individuals who distinguished themselves have a prolonged track record in it market. In some instances, it had been just reliant on swallowing the existing business model and making the logical leap to iphone 3gs apps. In others, the app was actually the start from the business and in some instances it could often always be the end of the road.  
+
* Auto-join
+
* Tabulation view
Don'testosterone be a one particular-hit wonder
+
* Many-to-Many
+
* Forms-processing
Several in the top paid apps were orphans or close, with only 1 to only two apps per developer. A lot more common, though, were developers with stables of 3 to 12 apps. Only 1 developer had a lot more than 15 apps. Successful developers leveraged existing products and apps, building on one to make others - but adapting a helpful app to make very similar spin-offs (iBeer, iMilk, iSoda, Magic Wallet), while smart, seems a little as well opportunistic. The app developers that have developed several special, compelling games are far more likely to have plenty of successes.
+
* require* library
+
* Entity->get_sid( ref, state )
In fact, 3 companies (Freeverse, Pangea Computer software, Electronic Arts) each and every had a couple of top-twenty apps. Just about all 3 are big or biggish companies, implying that it takes significant resources to product a winning app.  
+
* Entity::Create( serialized-state, is_new ). Checks schema()->cache before creating.
+
* Entity::LoadBySid
Don'capital t end up being way too hung way up on price
+
* Entity::LoadByKey
+
* Family album
The de facto standard apple iphone app price is truly $0.99. It level was quickly established in the App Store while the place where most buyers appeared happy. Probably it'ersus due to the standard cost of iTunes music.  
+
* Multiple accounts / sharing (by partitions)
+
* Pay for printing/binding
In case, nearly all of the winning apps command better prices, with 13 from the 20 priced through $1.99 way up, and 4 of them commanding the majestic (for iphone 4g apps) price of $4.99 on the day time we did the inspection.
+
* Address with photos/map
+
* Budget keeper
You don't need Lite or Free teaser apps
+
* CV/resume
+
* Fancy Invitation/RSVP
The following'utes a very interesting factoid. Only 2 of the top twenty apps (iHunt and iShoot) have a free or lite version, at least during the time of writing. Both developers are individuals fairly than companies, and it's interesting that the bigger outfits don't begin to see the need for teasers. The implication is actually that if it'utes worth buying, people will pay for it.
+
* Library (register of books owned)
+
* Fixing the object-relational impedence mismatch by using models for OLTP and arrays for reporting (e.g. HTML tables, pagination, sorting, joining, filtering, etc.)
The freebie iShoot Lite had two.4 million downloads in January, and there were 320,000 paid downloads. So it's very achievable that the free app drove sales with the paid app -- but it's even it can be that there might have been much more paid downloads had the free app not been available.  
+
* Session, Browser, User, Global config
+
* Principal (Browser, User) create table principal ( id, type(browser/user), {broswer,user}id )
You don'n need to be a huge company (even though it helps)  
+
* Contact and Service
+
* Articles and books. Draft and published. Shared with contact
Could it become that success in iphone 3gs apps depends on having substantial, sophisticated, expensive marketing strategies? Not necessarily.
+
* TODO list
+
* Link redirector and bookmarks
There'utes no question that it helps to always be Internet savvy and have strong pockets, but the winning app developers were an encouraging mix of sizes and types.
+
* File uploads and picture gallery. Public/private/shared.
+
* Calendar, date-picker
A number of from the 17 developers are big multinational companies -- Apple itself (Texas Keep'em), Electronic Arts (TETRIS, Monopoly), Activision (Crash Bandicoot) and SEGA (Super Monkey Ball). Then there are a bunch of mid-sized companies and, happily, in addition 7 simple groups and 4 individuals.
+
* Timesheets
+
* Surveys/Questionnaires
iFart Mobile is truly a great interesting story. It has been developed by an Internet marketing guru who realized how to deliver the results the system and get incredible publicity by causing a pointless app that he must have known would effortlessly build controversy, laughter and awareness.
+
* Interactive chat
+
* Session monitor (follow user sessions in real time in your browser, you see what they see)
The Internet mythology of smart guys working evenings or week-ends, or out from the garage, and hitting the jackpot, lives on. The little guys in this unique group are Henry Moffett (iHunt), Ethan Nicholas (iShoot) and, so far when we can inform you, Shinya Kasatani (Earn Guitar). These guys might not be the next Steve Jobs, however they have been successful to the tune of hundreds of thousands of dollars, just a dollar or two at a time. Very impressive.
+
* Email client
+
* RSS feeds
Controversy will be useful, but by no means crucial
+
* detect preferred language and if not English ask if the user will translate the content
+
** offer one month free at bkdb.com in exchange
iFart Mobile in particular, and with a lesser extent iBeer and iHunt, are quite controversial and almost certainly gained a lots of publicity for this reason. You can almost view the controversy in the ratings -- while the majority of the 20 top apps have a dominant rating of 5 stars, slowly dropping down, these 3 controversial apps had large numbers of ratings for both 5 stars and 1 star. So it distribution of rating might not hurt an app, and might show a developer that the app has a big potential to make buzz.
+
* table->ref( key_name, col_nam, ref_table, ref_col ) in Schema
+
* Instrument SlibDatabase and log SQL/time/etc to slib__sql_monitor
The other top apps did not seem meant to attract controversy which obviously didn'n hurt them.
+
* graphics management (database, scale, cache)
+
** gm()
Five-star ratings are neither important nor feasible for top apps
+
* file management (database, upload, cache)
+
** fm()
You can't make sure you each one of the people all the time -- so the a lot more ratings there are, the lower the odds of a 5 or even 4.5 star average. None with the top apps had 5 stars and most had 3 to 4 stars. iHunt had only two.5 stars, because a wide range of people hated it.
+
* form management (validation, submission(POST)/query(GET))
+
** form()
It takes a Large amount of downloads to develop a lots of ratings
+
** Submission inherits SlibSubmission
+
** Query inherits SlibQuery
Despite the fact that probably countless people collectively downloaded the 20 top apps, the highest number of ratings (Fieldrunners) has been 1,479 and the lowest (Earn God) had been 226. Most people don'testosterone offer ratings, and even fewer write reviews.
+
** Validator inherits SlibValidator
+
* content management (news, book, page)
Offered that people like to end up being element of a happy herd, it's almost certain that savvy developers actively promote positive ratings and reviews.  
+
** cm()
+
** Article (News) inherits SlibArticle (date, title, description, html)
The theme doesn't should be classic or familiar
+
** Book inherits SlibBook
+
** Chapter inherits SlibChapter
Classics like Texas Hold'em, Monopoly and TETRIS (just about all developed by public companies) did characteristic in the 20 top apps. The other apps were at times familiar, occasionally not, but none of them really adapted a big-name, well-known sport. Bank account Guitar, of course, used a well-loved instrument with great success. But to balance that, Ocarina catapulted a helpful obscure historic flute to fame.  
+
** Page inherits SlibPage
+
* translation facilities for content and services
Exceptional counts
+
** tm()
+
* access logging (all HTTP activity)
There are many, many, many mobile phone games with themes not dissimilar to the top games. There are dozens of guitar simulations. There are 5 other iFart apps. So just having a good notion isn'capital t adequate.
+
** log()
+
* error logging (write failed logins to error log, pick up with fail2ban)
The iFart apps are a helpful interesting illustration. Almost uniformly, these people have not developed a following, and the comments are mostly bad -- not because they're vulgar and silly, but because these people're not well executed and users don'big t like them.
+
** log()->error()
+
* request management (HTTP input/output)
Today you understand some with the secrets. Happy programming!
+
** req()
+
** redirection support: req()->goto( $url )
Findanapp is actually a simple, searchable database of all iPhone apps we can lay our hands on. Our site seems to have details of over 59,690 apps, and counting.
+
** cookie support: req()->cookie( $name, $etc )
   
+
** HTTP headers support: req()->header( ... )
http://nyro.org.uk/member/508057
+
* Category (for content, graphics, files)
 +
* Tag (for content, graphics, files)
 +
* Feed provider
 +
** feed()
 +
* sharding:
 +
** main_db, partition_*_db
 +
** log_db(), db( $partition_id )
 +
** same schema in all databases
 +
* create partition_* databases, one for each partition
 +
* partition load order and default partition in settings
 +
* database versions: global() and partition( $id )
 +
* user creation includes user's partition being created
 +
 
 +
== Technical specification ==
 +
 
 +
TODO.
 +
 
 +
== TODO ==
 +
 
 +
Things to do, in rough order of priority:
 +
 
 +
* Schema load
 +
* Partition: id, server, database, schema
 +
* Service Map: _gid, _app, _web, _000001 (partition 1)
 +
* gid: 0 = Null Object; +ve for existing GID, -ve for new GID
 +
* html2text..?
 +
* Internationalisation using _ function
 +
* Language messages in HTML, e.g. _('John's Message.')
 +
* Plural/singular
 +
* Upgrade GIT: Int24, Int32, Int64
 +
* Create the project in svn
 +
* Document functional specification
 +
* Document technical specification
 +
* Copy in existing code
 +
 
 +
== Done ==
 +
 
 +
Stuff that's done. Latest stuff on top.
 +
 
 +
* [[User:John|JE]] 2014-05-14: documenting functional specification
 +
* [[User:John|JE]] 2011-12-08: created project page
 +
 
 +
== Notes for implementers ==
 +
 
 +
If you are interested in incorporating ProgClub slib into your project, here's what you need to know:
 +
 
 +
You probably want to setup an svn:externals from your svn repository to the public release tag:
 +
 
 +
  https://www.progclub.org/svn/pcrepo/slib/tags/latest
 +
 
 +
That way you'll get changes to the framework as they're released. Beware, the interface is super volatile, it won't stabalise for a while.

Latest revision as of 15:18, 11 December 2017

Slib is the ProgClub PHP framework software. That's the software that provides a framework for your PHP applications. For other projects see projects.

Project status

Version 0.1 has been released and it's being used.

Version 0.2 is under way and isn't ready for release yet. There's stuff TODO.

Contributors

Members who have contributed to this project. Newest on top.

All contributors have agreed to the terms of the Contributor License Agreement. This excludes any upstream contributors who tend to have different administrative frameworks.

Copyright

Copyright 2011-2014, Contributors. Licensed under APACHE 2.0.

Libraries

The Slib software uses the following libraries:

Source code

The repository can be browsed online:

https://www.progclub.org/pcrepo/slib/branches

The code for slib is publicly available from svn:

https://www.progclub.org/svn/pcrepo/slib/tags/latest

Or privately available for read-write access:

https://www.progclub.org/svn/pcrepo/slib/branches

Links

No links at this time.

Functional specification

The software provides a web-framework/toolkit for PHP applications.

A new approach to dependency injection

The slib framework has a new approach to dependency injection. If you want to provide a mock/instrumented instance of any of the framework classes all you have to do is define the ClassName that you want to inherit from the SlibClassName. Your ClassName file will automatically be instantiated by the factory method that Creates/Loads your implementation. The way this works is that slib registers a mock-loader that will generate a concrete type if no concrete type is defined and the base implementation operates on the concrete type.

Database interface

There is a Database interface. Has support for DataSort sorting and DataPage pagination. There is no filtering support yet.

Database schema management

There is a DatabaseUpgrader that handles database schema migrations. There was some talk of factoring the SQL out into .sql files, but I think this format is easier to maintain/reference as all the table definitions are right there in the source.

Asset management

There is a ResourceManager and a compiler. The compiler bundles CSS and JavaScript, the ResourceManager handles requests for assets. Note: the compiler automatically generates .gz files for all assets so the ResourceManager can return them.

Support for graphics, style, scripts, and caching is provided by the ResourceManager.

Settings management

There is a Settings manager. It provides a layered approach to user settings. First we try to get a setting from the Session, then the User otherwise global default.

Session management

User sessions are managed by the Session component. Supports user login.

Authorisation management

There is an Auth component that defines authorisations for actions.

Role-based security

There is first-class support for User and Role facilitating role-based security.

URI/URL management

The SlibUri class and its associates provide an interface for reading and manipulating URIs. The following diagram illustrates the six types of URI supported and the component pieces:

SlibUriHierarchy-1.png

The software has been specifically designed to cater to specialised URI handling, such as seen with SlibMailtoUri which extends SlibUri with 'mailto' specific API such as get_mail_user(), get_mail_domain(), get_mail_subject(), etc., etc. At this time the only specialised URI is for mailto links, all other schemes are handled with URI types 1 to 5, most of them being a 4.

For a list of all documented URI schemes see URI scheme at Wikipedia. There is a code generator which generates the strong-typed URIs based on documented schemes. The idea is that the design caters for URIs to be scheme specific, but the design doesn't need to be done immediately. Presently the only real URI support is for schemes: http, https, file and mailto, the rest are generic for the time being.

Note: because of the decision to use 'strong-typed' classes on the API it is possible to do something odd. For example I could create a SlibHttpUri using ::Parse(...) and then on that URI change the scheme to 'mailto', I will then have a SlibHttpUri that reports its scheme as 'mailto', not 'http'. It's not a great design, but hey, it works if you don't push it and importantly: it's done!

Here's an example of using SlibUri for getting URL components:

$uri = SlibUri::Parse( "https://www.progclub.org/wiki/Main_Page", '/wiki' );
$this->assertSame( 'https', $uri->get_scheme() );
$this->assertSame( 'www.progclub.org', $uri->get_host()->to_string() );
$this->assertSame( '/wiki', $uri->get_base() );
$this->assertSame( '/Main_Page', $uri->get_path()->to_string();

$uri = SlibUri::Parse( "mailto:jj5@progclub.org?subject=test" );

$this->assertSame( 'jj5', $uri->get_mail_user() );
$this->assertSame( 'progclub.org', $uri->get_mail_domain()->to_string() );
$this->assertSame( 'test', $uri->get_mail_subject() );

$uri = SlibUri::Parse( "https://www.progclub.org/pcwiki/index.php?title=Main_Page&action=edit" );

$this->assertSame( '/pcwiki/index.php', $uri->get_path()->to_string() );
$this->assertSame( 'pcwiki', $uri->get( 1 ) );
$this->assertSame( 'index.php', $uri->get( 2 ) );
$this->assertSame( 'index.php', $uri->get_filename() );
$this->assertSame( 'php', $uri->get_extension() );
$this->assertSame( 'Main_Page', $uri->get( 'title' ) );
$this->assertSame( 'edit', $uri->get( 'action' ) );

And here's an example of using SlibUri to build URLs:

$uri = SlibUri::Parse( "https://www.progclub.org/wiki/Main_Page", '/wiki' );

$uri = $uri->to_builder();

$uri->set( 'q', 'testing' );

$this->assertSame( "https://www.progclub.org/wiki/Main_Page?q=testing", strval( $uri ) );

$uri->set( 'a', array( 1, 2, 3 ) );

$this->assertSame( "https://www.progclub.org/wiki/Main_Page?q=testing&a=1&a=2&a=3", strval( $uri ) );

$uri->clear( 'q' );
$uri->clear( 'a' );

// set the 4th path part:
$uri->set( 4, 'test' );

$this->assertSame( "https://www.progclub.org/wiki/Main_Page//test", strval( $uri ) );

TODO

  • Support for Min/Max defaults and specific validation
  • TableView->name for use in sort/page/etc slugs (defaults to 'defalut')
  • TableView->read_{selected,searched}_columns and ensure they are valid.
    • If they are not valid remove the offending parameter and redirect
  • Joins omitted by selected columns
  • Per entity database references (remove dependency on db singleton)
  • Partition management
  • DB Aggregator
  • Auto-join
  • Tabulation view
  • Many-to-Many
  • Forms-processing
  • require* library
  • Entity->get_sid( ref, state )
  • Entity::Create( serialized-state, is_new ). Checks schema()->cache before creating.
  • Entity::LoadBySid
  • Entity::LoadByKey
  • Family album
  • Multiple accounts / sharing (by partitions)
  • Pay for printing/binding
  • Address with photos/map
  • Budget keeper
  • CV/resume
  • Fancy Invitation/RSVP
  • Library (register of books owned)
  • Fixing the object-relational impedence mismatch by using models for OLTP and arrays for reporting (e.g. HTML tables, pagination, sorting, joining, filtering, etc.)
  • Session, Browser, User, Global config
  • Principal (Browser, User) create table principal ( id, type(browser/user), {broswer,user}id )
  • Contact and Service
  • Articles and books. Draft and published. Shared with contact
  • TODO list
  • Link redirector and bookmarks
  • File uploads and picture gallery. Public/private/shared.
  • Calendar, date-picker
  • Timesheets
  • Surveys/Questionnaires
  • Interactive chat
  • Session monitor (follow user sessions in real time in your browser, you see what they see)
  • Email client
  • RSS feeds
  • detect preferred language and if not English ask if the user will translate the content
    • offer one month free at bkdb.com in exchange
  • table->ref( key_name, col_nam, ref_table, ref_col ) in Schema
  • Instrument SlibDatabase and log SQL/time/etc to slib__sql_monitor
  • graphics management (database, scale, cache)
    • gm()
  • file management (database, upload, cache)
    • fm()
  • form management (validation, submission(POST)/query(GET))
    • form()
    • Submission inherits SlibSubmission
    • Query inherits SlibQuery
    • Validator inherits SlibValidator
  • content management (news, book, page)
    • cm()
    • Article (News) inherits SlibArticle (date, title, description, html)
    • Book inherits SlibBook
    • Chapter inherits SlibChapter
    • Page inherits SlibPage
  • translation facilities for content and services
    • tm()
  • access logging (all HTTP activity)
    • log()
  • error logging (write failed logins to error log, pick up with fail2ban)
    • log()->error()
  • request management (HTTP input/output)
    • req()
    • redirection support: req()->goto( $url )
    • cookie support: req()->cookie( $name, $etc )
    • HTTP headers support: req()->header( ... )
  • Category (for content, graphics, files)
  • Tag (for content, graphics, files)
  • Feed provider
    • feed()
  • sharding:
    • main_db, partition_*_db
    • log_db(), db( $partition_id )
    • same schema in all databases
  • create partition_* databases, one for each partition
  • partition load order and default partition in settings
  • database versions: global() and partition( $id )
  • user creation includes user's partition being created

Technical specification

TODO.

TODO

Things to do, in rough order of priority:

  • Schema load
  • Partition: id, server, database, schema
  • Service Map: _gid, _app, _web, _000001 (partition 1)
  • gid: 0 = Null Object; +ve for existing GID, -ve for new GID
  • html2text..?
  • Internationalisation using _ function
  • Language messages in HTML, e.g. _('John's Message.')
  • Plural/singular
  • Upgrade GIT: Int24, Int32, Int64
  • Create the project in svn
  • Document functional specification
  • Document technical specification
  • Copy in existing code

Done

Stuff that's done. Latest stuff on top.

  • JE 2014-05-14: documenting functional specification
  • JE 2011-12-08: created project page

Notes for implementers

If you are interested in incorporating ProgClub slib into your project, here's what you need to know:

You probably want to setup an svn:externals from your svn repository to the public release tag:

https://www.progclub.org/svn/pcrepo/slib/tags/latest

That way you'll get changes to the framework as they're released. Beware, the interface is super volatile, it won't stabalise for a while.