-
Notifications
You must be signed in to change notification settings - Fork 0
01. How To's
-
Download the framework from github, you can find the most recent version on the releases tab.
-
Unzip
Smts_Base-master.zipand place theframeworkfolder into your web-root, for exampleC:/xampp/htdocs/. -
Optionally, change the
frameworkfolder to your project name. -
Edit the following lines in your
base/config.phpfile:BaseUrl,DataBaseName,DataBaseUser,DataBasePassword.For more information on what you should change them to, see the Config wiki entry.
-
Run the database setup at
/dev/setup, this will create the database and add some default users.
A page is an Action, a Controller is a group of actions bound by a category, and a View is the HTML used to display an Action to the user.
For simple and advanced examples see the files pagesController and usersController respectively.
In the following example the controller will be called foo and the action bar, to view this page you would go to /foo/bar. To add a new Controller, Action, and View you need to create two files: controllers/foo_controller.php and views/foo/bar.php. To only add an Action and view simply add the method to an existing Controller and change foo to that Controllers name.
<?php // controllers/foo_controller.php
class fooController extends Controller {
public static function bar() {
Smts::Render('foo/bar');
}
}<!-- views/foo/bar.php -->
<div class="row">
<div class="col">
<h1>Your content</h1>
</div>
</div>-
First create the database table using the setup tool.
-
In the
base/database_struct.phpfile in thegetStructuremethod add a new array entry at the top of the array. The key of that entry is what the table will be called and the value is an array. -
In that array add the names of the columns as keys, and the datatype and length as values.
-
If your table contains any primary keys add them to the
primaryKeysarray entry, with the table name as key and the name of the primary key as value. -
Now go to
/dev/setupand reload the database with the new structure.
-
-
Then to add the model, create a file in the
modelsfolder with the name of the database table suffixed with.php.Below is an example of a simple user Model.
<?php // models/user.php class User extends model { public $id; public $name; public function rules() { return [ [ ['name'], 'required' ], [ ['name'], 'unique' ], [ ['name'], 'type_string' ], ]; } public function attributes() { return [ 'name' => 'Name' ]; } public static function find( $id ) {...} public function save() {...} public function delete() {...} }