FuelPHP PHP App

FuelPHP

by FuelPHP

PHP 5.4 framework
Helps with: PHP,Web Frameworks
Similar to: ThinkPHP App Yii 2.0 App Flow App Silex App More...
Source Type: Open
License Types:
MIT
Supported OS:
Languages: Other

What is it all about?

FuelPHP is a simple, flexible, community driven PHP 5.3+ framework, based on the best ideas of other frameworks, with a fresh start!

Key Features

◾Full HMVC implementation ◾ ViewModels to get the View-specific logic out of your Views and Controllers ◾ Route directly to closures ◾Extend or replace Core classes without rewriting a single line of code. ◾ Package additional functionality into Packages. ◾ Create modular application by dividing it up into Application Modules. ◾Input filtering ◾ URI filtering ◾ XSS filtering ◾ Output encoding ◾ CSRF token protection ◾ SQL injection prevention ◾ A secure Auth framework ◾Code generation, Scaffolding and Admin generation. ◾ Run Database Migrations. ◾ Interactive Debugging. ◾ Tasks - useful for cron type activities like importing data and other batch or background operations. ◾ Controller_Template - Add simple page templating functionality to your controllers. ◾ Controller_Rest - An easy way to create a RESTful API. ◾ Controller_Hybrid - Combine the two features into a single controller. ◾ Model_Crud - Provides all methods for CRUD operations on a single table. ◾ OO way of working with database data and performing CRUD operations. ◾ All normal relationship types: belongs-to, has-one, has-many, many-many ("has and belongs to many"). ◾ Fetch relations of relations of relations of...etc... in one go ("nested relations"). ◾ Cascading saves and deletes for related objects. ◾ Entity Attribute-Value model implementation. ◾ Model extensions that implement: Soft-delete functionality (mark records as deleted instead of actually removing them) Temporal functionality (automatic versioning of records on every update) Nested sets functionality (store hierarchical structures (trees) into a database table) ◾ Use Observers to update/process the objects instances, for example to validate before saving or to auto-update an updated_at property. ◾ Included simple authentication for users, groups & basic ACL. ◾ Or full-featured RBAC authentication based on ORM if you need it. ◾ Secure hashing function for passwords included (PBKDF2). ◾ OAuth integration for social media authentication. ◾ Default interface for any Auth library in FuelPHP.


Pricing

Yearly
Monthly
Lifetime
Free
Freemium
Trial With Card
Trial No Card
By Quote

Description

free - see site

Product Analysis

PHP

PHP frameworks and libraries

FuelPHP Review

FuelPHP Review

By Alvie Amar | 6/9/2016 | Product Analysis |Beginners

FuelPHP is a flexible, simple, open source web application framework written in PHP that actualizes the HMVC design. FuelPHP grew out of the dissatisfactions that many individuals had with the current available frameworks and was developed with support from a group of developers. FuelPHP works with any server and prides itself on clean syntax, while being extremely portable.

 

In late 2010, the framework was started by Dan Horrigan then in a short time Phil Sturgeon, Jelmer Schreuder, Harro Verton, Frank de Jonge, Steve West and Márk Sági-Kazár joined the group. The group has many years of PHP experience amongst them and have all been involved with open-source projects such as CodeIgniter, PyroCMS, ExciteCMS and DataMapper ORM to name but a few.

 

What does FuelPHP have to offer? The following are some of the key features of FuelPHP:

  • Full HMVC usage
  • Package extra functionalities
  • Avoid Xss attacks
  • Interactive debugging, run database migrations and code generation
  • Simple approach to make a RESTful API
  • Provides all methods to CRUD
  • Effective yet lightweight ORM
  • Verification Framework
  • Can utilize any layout parser for the views
  • A caching system

 

What is FuelPHP good for?

 

As of now, there are lots of frameworks on the market, so why FuelPHP? Well, FuelPHP as of now takes an alternative approach as opposed to other frameworks in that it is community-driven. When creating projects, FuelPHP can be useful since it provides a solution for average web application needs. Aside from that, FuelPHP comes with support for HMVC. The delightful thing about HMVC being packaged inside the core is that upgrades will dependably bolster the modular usefulness and functionality, not to mention that you are not forced into using a modular architecture as a part of your application, but it's there if you need it. Additionally, FuelPHP also has a powerful ORM class which is useful in that it can be of great of help for a cleaner method for communicating with a database in contrast to other frameworks.

 

The following are some advantages of FuelPHP:

  • There are very few restrictions on the most proficient method to compose code. Classes can be in any file structure.
  • FuelPHP is an enormous, group-driven framework used for web development.
  • Libraries and constant alterations were being produced and released which keeps the framework advancing even while the core is moving at a slower pace as of late.
  • Fuel does not force you to use modules or an HMVC file structure, however in the event that one chooses to implement them, the procedure is well documented and quite easy to integrate.
  • Gives a chance for one module in the new application and ended up using it for each module in this way.
  • FuelPHP is fast, small and permits developers to create web based applications rapidly. It is completely extensible and includes built-in modules and package support.
  • FuelPHPs’ views will encode all output to make it secure and prevent XSS assaults.

 

Examples and code snippets

 

Let’s get started working with some basics in Fuel.

 

Make sure to enable the following two packages in app/config/config.php :

'packages'  => array(
   'orm',
   'auth'
)

We will use this code in the next section. The default route is hello, which demonstrates your welcome page. If you would like to perform some changes, you can edit fuel/app/config/routes.php: 

return array(
   '_root_'  => 'welcome/index',  // The default route
   '_404_'   => 'welcome/404',    // The main 404 route
   'hello(/:name)?' => array('welcome/hello', 'name' => 'hello')
);

 

Now let's look at the proper way to say hello to the world of fuel. First, make a basic yet simple authentication app by means of Simpleauth. Simpleauth refers to a basic verification system which is incorporated into the auth package. To use Simpleauth, duplicate fuel/packages/auth/config/auth.php and simpleauth.php to fuel/app/config/. At that point, make a database table. Use migration rather than traditional database operations. Copy core/config/migrations.php to app/config/migrations.php and run the following command to create a scaffold: 

php oil generate scaffold user username:string password:string email:string profile_fields:text  created_at:string updated_at:string last_login:integer[20]

This will make a file in the app/migrations folder named 001_create_users.php, which edited as:

namespace Fuel\Migrations;
class 001_create_users
{
   public function up()
   {
    \DBUtil::create_table('users', array(
           'id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true),
           'username' => array('constraint' => 255, 'type' => 'varchar'),
           'password' => array('constraint' => 255, 'type' => 'varchar'),
           'email' => array('constraint' => 255, 'type' => 'varchar'),
           'last_login' => array('constraint' => 20, 'type' => 'int'),
           'profile_fields' => array('constraint' => 255, 'type' => 'varchar'),
           'created_at' => array('constraint' => 255, 'type' => 'varchar'),
           'updated_at' => array('constraint' => 255, 'type' => 'varchar')
       ), array('id'));
 
       $username = "AwesomeFuel";
       $password = "@awesomeFuel@";
       $pass_hash = \Auth::instance()->hash_password($password);
       $email = "Fuel@is-awesome.au";
       $users = \Model_User::forge(array(
           'username' => $username,
           'password' => $pass_hash,
           'email' => $email,
           'profile_fields' => '',
           'last_login' => ''
       ));

       if ($users and $users->save())
           \Cli::write("the user has been created");
        else
           \Cli::write("failed to create user");
   }
   public function down()
   {
       \DBUtil::drop_table('users');
   }
}

 

To check the code above submit this, you will just need to run php oil refine migrate.

 

After this, please create a Common controller in app/classes/controller/common.php:

 

class controller_common extends Controller_Template
{
   public function before()
   {
       parent::before();
       $uri_string = explode('/', Uri::string());
       $this->template->logged_in = false;
 
       if (count($uri_string)>1 and $uri_string[0] == 'users' and $uri_string[1] == 'login')
           return;
        else
          {
           if(\Auth::check())
           {
               $user = \Auth::instance()->get_user_id();
               $this->user_id = $user[1];
               $this->template->logged_in = true;
           }
           else
               \Response::redirect('/users/login');
          }
   }
}

 

And the user controller is located in app/classes/controller/users.php:

 

class controller_users extends Controller_Common
{
   public function action_index()
   {
       $data['users'] = Model_User::find('all');
       $this->template->title = "Users";
       $this->template->content = View::forge('users/index', $data);
   }
 
   public function action_login()
   {
       if (Auth::check())
           Response::redirect('/');
       $val = Validation::forge('users');
       $val->add_field('username', 'Your username', required|min_length[3]|max_length[20]');
       $val->add_field('password', 'Your password', required|min_length[3]|max_length[20]');
 
       if ($val->run())
       {
           $auth = Auth::instance();
           if ($auth->login($val->validated('username'), $val->validated('password')))
           {
               Session::set_flash('notice', 'FLASH: logged in');
               Response::redirect('users');
           }
           else
           {
               $data['username'] = $val->validated('username');
               $data['errors'] = 'Wrong username/password. Try again';
           }
       }
       else
       {
           if ($_POST)
           {
               $data['username'] = $val->validated('username');
               $data['errors'] = 'Wrong username/password combo. Try again';
           }
           else
           {
               $data['errors'] = false;
           }
       }
 
      $this->template->errors = $data['errors'];
      $this->template->content = View::forge('users/login')->set($data);
   }
 
   public function action_view($id = null)
   {
       $data['user'] = Model_User::find($id);
       $this->template->title = "User";
       $this->template->content = View::forge('users/view', $data);
   }
 
   public function action_logout()
   {
       Auth::instance()->logout();
       Response::redirect('/');
   }
}

 

As what you can see, the controller extends Controller_Common in order to be restricted by log-in. Additionally, the input data in the controller is also validated, but it could be in the model, as well.

 

Once you're done with the controllers it's time to make a view for the application. In Fuel, the view files are situated under app/views/CONTROLLERNAME/. The first view to make is app/views/users/login.php:

<h2>Login</h2>
Login to your account using your username and password.
<div class="input required">
   <?php isset($errors) ? $errors : false; ?>
   <?php echo Form::open('users/login'); ?>
   <?php echo Form::label('Username', 'username'); ?>
   <?php echo Form::input('username', null, array('size' => 30)); ?>
</div>
 
<div class="input password required">
   <?php echo Form::label('Password', 'password'); ?>
   <?php echo Form::password('password', null, array('size' => 30)); ?>
</div>
 
<div class="submit" >
   <?php echo Form::submit('login', 'Login'); ?>
</div>

 

And now, the index.php file:

<div><?php echo $user->username; ?></div>

 

Then navigate http://127.0.0.1/public/users/login in your browser. Enjoy!! 

 

Conclusions

 

Web development is a dynamic field with new and innovative techniques being developed all the time. Numerous PHP frameworks offer broad, extensive designs with exclusive features that make source code programming less confounded by giving standard templates and plugins. If you are concerned that a framework lacks an authentication library, ORM and PHP5 compatibility, then FuelPHP is presumably the perfect choice. FuelPHP is another section of the IT market. FuelPHP is a nice bridge framework for a Codeigniter developer. The structure is generally the same, expectation to learn and adapt is for the most part the same and the documentation is getting very strong. FuelPHP does a lot of heavy lifting for you. Everything is up to you on what framework are you comfortable with. So if you're looking to broaden your expertise, then FuelPHP may be the right framework for you.

By Alvie Amar | 6/9/2016 | Product Analysis

{{CommentsModel.TotalCount}} Comments

Your Comment

{{CommentsModel.Message}}

Top DiscoverSDK Experts

User photo
3355
Ashton Torrence
Web and Windows developer
GUI | Web and 11 more
View Profile
User photo
1490
Ronan McCarthy
Cross-Platform & Web developer.
Web | Mobile and 6 more
View Profile
User photo
1230
Gary Green
Expert programmer, Ask what you want
Web | JavaScript and 3 more
View Profile
User photo
1130
Harry Gold
Experienced Web developer.
Web | JavaScript and 3 more
View Profile
Show All

Interested in becoming a DiscoverSDK Expert? Learn more

X

Compare Products

Select up to three two products to compare by clicking on the compare icon () of each product.

{{compareToolModel.Error}}

Now comparing:

{{product.ProductName | createSubstring:25}} X
Compare Now