A php framework to help programmers like me to create web applications easy and fast
PHP JavaScript Other
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
core
files
project
www
.gitignore
README.md

README.md

SSX PHP FRAMEWORK

A php framework to help programmers like me to create web applications easy and fast

Ssx is compatible with PHP 5.4 or newer

Installation

These steps below is like any php application but pay attention for details like startup folder"

  1. Copy all files one step back from your domain folder. If your domain runs on www/ or http/ paste all files on the same folder not inside these folders.

  2. To edit database acces you'll need to execute files/hash.php on apache/nginx to generate encrypted database information.

    files/hash.php does not work alone. Dont move this file to a new folder

  3. Open your database and execute files/base_ssx_mysql.sql.

  4. Create one environment variable called APPLICATION_ENV with value development. Set to production on final server

  5. Open project/set/config_set.php and replace encrypted informations generated by files/hash.php. Remember to set these values relacted with APPLICATION_ENV value.

  6. In your apache/nginx and set your domain to run on www/ folder

  7. Execute your domain. You'll see this message: Database updated. Refresh this page to continue and your application is almost ready.

  8. Now you'll need to set access permission on admin. Access yourdomain/admin/. user: administrator and password: 123456 Change this password as soon as possible. Seriously.

Application - Creating Pages

This framework uses Smarty PHP to compile views but dont worry about that.

The base concept to create page is Module/Action. Each module have your own actions. For example:

yourdomain.com/category/create

By default you have module home and action index if you access yourdomain.com/ this action will be called.

###Create a new page###

For example: lets create yourdomain.com/contact

  1. Open project/modules/Home folder and create an empty php file called contact.php

  2. Inside project/modules/Home/templates/ create a new file called contact.tpl. .tpl extension will be your html file

  3. Access yourdomain.com/contact you will see Access denied because the framework have ACL control and you'll need to give for the guests permission to access this page.

  4. Open yourdomain.com/admin (login required). Access yourdomain.com/ssxacl/edit or use navigation menu to "Access permission". Change the access group to guest and allow the access.

Done. Now your page is working

###Creating new module###

The process is the same. Duplicate projects/modules/Home folder and rename to your desired module.

Create any pages you want inside this folder.

Remember: For each page you create you'll need to change Access permission to work.

  • The framework creates automatic Routes and generate permalinks based on your module/action.

Application - Creating and Using Commom Classes

  1. Create a new php file called ClassDesired.php inside project/control/

  2. Create a syntax class

<?php
class ClassDesired
{
	public function DoSomething()
	{
		//do something
	}
}
  1. To Access inside your pages. Open yourpage.php inside project/modules/YourModule/
<?php

$ClassDesired = new ClassDesired();
$ClassDesired->DoSomething();

This is it. Simple and easy. This method can be used to acces inside or outside your page.

Application - Creating and Using Database Table Classes

  1. Create a new php file called ClassDesired.php inside project/control/

  2. Create a syntax class. You'll need to extend to SsxModels class to access database

  3. Inside your class put some informations about your table from database

<?php
class ClassDesired extends SsxModels
{
	// full table name
	public $table_name = "table_example";
	
	// will be used internally to create JOIN between tables
	public $prefix = "TE";
	
	// fields from this table
	// you'll need to set the type of your field
	// Available types: int, string and datetime
	public $fields = array(
		'id'=>'int',
		'date_created'>'datetime',
		'name'=>'string',
		'email'=>'string',
		'priority'=>'int',
		'status'=>'int'
	);
}
  1. Now your class is ready to access database

To save/edit data###

To Access inside your pages. Open yourpage.php inside project/modules/YourModule/

<?php

$ClassDesired = new ClassDesired();

To save data you can use

$id = null; // if you want to edit or non-autoincrement add ID info.

$arrayData = array(
	'id'=>$id,
	'name'=>'Jasiel',
	'email'=>'jasiel@email.com',
	'priority'=>1,
	'status'=>1
);

// return the saved/generated id
$savedID = $ClassDesired->saveValues($values,$generate_guid=true /* only if you want to use GUI on your IDs */, $editing_check=true /* if true. will be executed UPDATE sql query if primary key is not NULL or EMPTY*/);

To List data###

  • Simple list
$dataToFilter = array(
	'email'=>'jasiel@email.com'
);

$result = $ClassDesired->filterData($dataToFilter, $one=false /* if true will return the first result and nothing more*/);
  • Complex list
$dataToFilter = array(
	'AND'=>array(
		array(
			'field'=>'name'
			'compare'=>'LIKE'
			'value'=>'%Jasi%'
		)
	)
);

$orderby  = "name";
$ordersort = "ASC";
$limitResult = 10; // 0 is equal no limits
$page = 0; // To paginate your results


$result = $ClassDesired->fetch($dataToFilter, $orderby, $ordersort, $limitResult, $page);

Security - Admin Additional Changes

In first instance your admin folder is opened to public access but you can change that. Follow these steps for your own risk.

  1. Move www/admin folder to out from www/ and rename to www_admin/

  2. Move project/admin to out from project/

  3. Edit www_admin/index.php to include core/core.php correctly

  4. Edit constant values www_admin/index.php to reference project location correctly

	define( 'LOCALPATH',   realpath(dirname(__FILE__) . "/../admin") . '/' );
	define( 'LOCALLOWPATH', dirname(__FILE__) . '/' );
	define( 'PROJECTPATH',realpath(constant("LOCALPATH") . "../project")."/");
  1. In your apache/nginx and set your sub-domain admin area to run on www_admin/ folder

  2. Copy www/resouces/ to www_admin/resources

Additional Notes

A lot of programmers loves composer except me and because of that the Ssx framework does not have external dependences. Like i said on the beginning this framework is to help programmers to create easily and fastest web application.

Some messages is localized in portuguese. I'll change that soon.

All erros messages does not trigger any kind of Exception but you can find all errors in your errors_log. The idea is change this in the future to improve debugs.

And finally: My english is horrible, i know! Sorry for that!