Introduction to Webiness
-
Naming convention
database tables
For best practice, we propose the following naming conventions for database tables and columns. Note that they are not required by Webiness.
- both database tables and columns are named in lower case.
- words in a name should be separated using underscores (e.g. product_order).
- table names may be prefixed with a common token such as tbl_. This is especially useful when the tables of an application coexist in the same database with the tables of another application. The two sets of tables can be readily separate by using different table name prefixes.
code
- Webiness recommends naming variables, functions and class types in camel case which capitalizes the first letter of each word in the name and joins them. Variable and function names should have their first word all in lower-case, in order to differentiate from class names (e.g. $basePath, runController(), LinkPager). For private class member variables, it is recommended to prefix their names with an underscore character (e.g. $_actionList).
- Because namespace is not supported prior to PHP 5.3.0, it is recommended that classes be named in some unique way to avoid name conflict with third-party classes. For this reason, all Webiness framework classes are prefixed with "Ws_".
- A special rule for model and controller class names is that they must be appended with the words Model and Controller. The controller ID is then defined as the class name with first letter in lower case and the word Controller truncated. For example, the PageController class will have the ID page. This rule makes the application more secure. It also makes the URLs related with controllers a bit cleaner (e.g. /index.php?r=page/index instead of /index.php?r=PageController/index).
files
- Class files should be named after the public class they contain. For example, the SiteController class is in the SiteController.php file. A public class is a class that may be used by any other classes. Each class file should contain at most one public class. Private classes (classes that are only used by a single public class) may reside in the same file with the public class
- View files should be named after the view name. For example, the index view is in the index.php file. A view file is a PHP script file that contains HTML and PHP code mainly for presentational purpose.
-
Webiness directory structure
After unpacking webiness archive, into your Web-accessible folder, you will see next directory structure:
application directory
This directory contains application logic of your application. Becouse webiness framework follows Model-View-Controller (MVC) design pattern, in toplevel of this directory you will find three additional directories:
- controllers: contains controller classes
- models: contains model classes
- views: stores controller actions view scripts
Note: for each controller class you must create sub-directory under "views" directory and put coresponding view files under that directory.public directory
contains all files that are shared between web pages like: css, images, layout file, javascript files, etc.lang directory
contains translation text files which are used to translate messages from your application into web browser's default language.runtime directory
stores dynamically generated files.Note: Web server must have write permission on this directoryprotected and doc directories
these are framework's internal directories. protected directory contains framework classes and javascript libraryes and doc contains framework's class reference documentation.
-
Webiness configuration file
Under protected/config directory, there is file named config-example.php. That file contains basic config options needed by Webiness.
All config options are set by calling static function WsConfig::set('config_option', 'config_value') and can be accessed by calling static function WsConfig::get('config_option').
Config options are divided in two categories:-
reserved options for Webiness framework
- db_driver - database driver / type of db server
- db_host - TCP/IP address of database server
- db_port - TCP/IP port of database server
- db_name - database name
- db_user - database user
- db_password - password for database user
- app_name - application name
- app_stage - development stage of application (verbosity of error messages)
- app_tz - timezone used for PHP date/time functions
- html_layout - name of default layout file
- auth_admin - email address for site administrator
- pretty_urls - enable or disable use of sementic (pretty) URLs in web application
- other, user defined options
Before you even start to develop with Webiness, you must copy (or move/rename) protected/config/config-example.php file to protected/config/config.php and edit config options to suit your needs. -
reserved options for Webiness framework
-
Webiness CSS framework
To keep small size and high speed of page loading, Webiness use it's own small CSS framework, instead of bootstrap, foundation or etc. Webiness CSS framework is located in public/css/webiness.css and public/css/webiness.min.css files.
Basic features include:- a responsive, mobile friendly, grid system with up to 12 columns
- row class to create horizontal groups of columns
- column class to create column and column-* class to define width of column where * is number from 1 to 12
- move columns to the right using column-offset-* class. This class incrise left margin of column by * columns
- create multilevel responsive navigation header with use of ws-header class
- align texts with three alignment classes text-left , text-right and text-center
- responsive tables
- global styling for form controls
- pagination class in ul element to create pagination links
- link-button class for button styling
- create message boxes with callout class
- color classes: primary, text-primary, success, text-success, warning, text-warning, error, text-error
Webiness CSS framework is included in default layout file for web application. Of course, you can use any other CSS framework's with Webiness, but we recomend that you keep webiness.css beside them becouse some Webiness components depends on it (WsModelGridView for instance).
Read our basic tutorial to learn how to make basic MVC application in Webiness.