Category Archives: Articles

Article related to web development,software development,mobile development and job interview based on IT. Explaining single topic from WordPress, PHP , MySQL etc.Helpful articles, tips and interview questions answers and discussion about them. Articles are very relevant to interviews and questions asked in them.

MVC Web Development Framework

What is Web Development Framework?

There is a huge number of server-side scripting languages, using them we can create web applications. Almost the scripts are full-fledged programming language and featured with Object Oriented Programming Systems. Popular of them are Java, PHP, Python, Ruby,Perl. At the early age of web the applications were built on conventional logic and components, are not organized or not reusable. As the next generation, web development technologies came into existence the requirement of frameworks increased.A need for such a tool was very important as they are time and cost efficient.

Now we have many frameworks with huge communities. Frameworks are the collection of basic building blocks and reusable code in an organized manner where maintenance and development both are painless processes. They implement code re-usability, inheritance, security, abstraction, accessibility, integrity, reliability, readability, maintainability in our applications. Now we are able to develop very robust applications in very less time. frameworks are enriched with various libraries and plugin. They also provide flexibility to extend the functionality of the core. Almost the framework is based on Model-View-Controller or MVC development pattern.

What is MVC?

MVC is a software architectural pattern, which provides a modular structure to an application and application is layered into Models(M), Views(V) and Controllers(C).

MODEL

Model is a layer where all the data building logic is present. This layer is abstract from direct access. We write or database queries and fetch and format data in this layer with given parameters. This layer is a central layer of all three.

VIEW

A view is a presentation layer. We see the desired results here in our browser. The user directly communicates with forms and perform actions and submit inputs. This is an end user layer where HTTP response displayed and request triggered by user actions.

CONTROLLER

A controller is an intermediate layer and create a pool between Model the data logic layer and View the representational layer. It collects user actions based on URI and parameters. Routing and reverse routing happen here.

Advantages of MVC Frameworks:

  1. Fast and quick development of complex web-applications.
  2. Collection of Plugins are available for most of the general purpose activities.
  3. Easy maintenance and debugging. Frameworks provide debugger kit , that eases the debugging process.
  4. MVC provides a modular structure to application that is why MVC based applications are flexible and robust.
  5. Most of them provide Database manipulation library, so no need to write custom and complex queries very often.
  6. Inbuilt security and migration features.
  7. Most of them come with a command-line interface to generate code-snippets and modules.
  8. They create SEO friendly URLs to easy for search engines to recognize your application urls.

What are the popular MVC framework based on PHP?

There are numerous MVC framework based on PHP. Some of them are as:
Laravel – Laravel is the most popular PHP framework with the latest release of PHP and suitable for heavy applications.It comes with Inbuilt Authentication and security features. Laravel has a powerful ORM and query builder. Laravel has a unique feature of artisan CLI tool.Blade template engine is used for presentation on view.

Zend Framework

Created by the developers of PHP.Zend Framework is a collection of professional PHP packages with more than 345 million installations. It can be used to develop web applications and services using PHP 5.6+, and provides 100% object-oriented code using a broad spectrum of language features. Zend Framework uses Composer as a package dependency manager; PHP Unit to test all packages; and Travis CI as a Continuous Integration service. Zend Framework also follows PHP-FIG standards and includes an implementation of PHR-7 for HTTP message interfaces (as shepherded by Matthew Weier O’Phinney, Zend Framework project lead).

CakePHP

CakePHP is a Rapid development framework written in PHP 5.6 and having a unique feature of Naming Convention. CakePHP has a powerful tool of bake console. We can create scaffolding within no time. It is suitable for Web services as well as small and heavy applications. We can use a template engine as well for the presentation layer.

Codeigniter

This is a zero-configuration framework and mostly used for small scale application. It comes with all the features of OOPS and security parameters. It is fast ,and the most flexible among others in a group. Code-igniter has wonderful and organized documentation and a huge community over the web. Codeigniter also provide the feature of HMVC and templating.

Yii

Fastest growing over the internet and popular in recent years. Featured with MVC structure and can be used for small as well as heavy applications. It handles complex WSDL services easily.

Phalcon

Phalcon is a secure and well documented MVC framework. It is suitable for any type of applications. It has implemented with very high-security level.

Spread the love

What is New In CodeIgniter 4.x?

As we all know CodeIgniter is a PHP lightweight MVC framework.

It provides us fast, flexible, and secure techniques to develop PHP based applications.

The Codeigniter 4.x alpha and beta are released but the available version is not recommended for production use.

The flexibility of Codeigniter is maintained as usual along with the advancement of compatibility with PHP 7.

 

Core Features of CodeIgniter


  • CI is an MVC framework with a small footprint.
  • Codeigniter gives exceptional performance.
  • This is an MVC  framework with zero configuration.
  • No command-line configuration setup or dependencies installation to start(Optional).
  • CI is not restricted to any naming convention or coding rules.
  • No need to learn about advanced concepts like PEAR.
  • You do not need to learn template engine rendering. 
  • Simple, Clear and easy to understand documentation.

Features of Codeigniter 4.x


  1. The earlier versions of Codeigniter are based on PHP 5.6 or lower but the Codeigniter 4 will be featured with PHP 7.2 functionality and compatibility.
  2. It required the *intl* extension of PHP installed on the server.
  3. If we would like to use CURLRequest, we will need lib curl installed.
  4. Supported databases are:
    1. MySQL (5.1+) via the MySQLi driver
    2. PostgreSQL via the Postgre driver
    3. SqLite3 via the SQLite3 driver
  5. CodeIgniter 4 can also be used with command-line programs. As per the latest trend, most of the frameworks provide CLI usability and library. Since Codeigniter 4.x the framework will also be providing CLI interfaces for different purposes.
  6. The following PHP extensions should be enabled on your server: 
    1. Php-json
    2. Php-mbstring
    3. Php-mysqlnd
    4. Php-xml
  7. If you want to use CURLRequest in your CI application, you will need to install libcurl.
  8. The framework now provides for a public folder, intended as the document root for your app
  9. Hooks in Codeigniter are a great feature in is maintained and improved as well.

How to install Codeigniter 4?



Codeigniter 4 can be installed using many methods

  • In Manual Installation, you need to download the latest release from official site and can place it in your www directory after extracting it.
  • If you want to use the composer tool you need to install the composer first and then you can install using command line. Composer will also help you to add third-party plugins in your project in the future. You can download and install the composer from this link: https://getcomposer.org/
  • You can also clone the git repository of CodeIgniter.

Directory Structure for Codeigniter 4.x



A newly installed application has six directories:

  1. application
  2. system
  3. public
  4. writable
  5. tests
  6. Docs

Application Structure

  1. The framework still has app and system folders, with the same interpretation as before
  2. The framework now provides for a public folder, intended as the document root for your app
  3. There is also a writable folder, to hold cache data, logs, and session data
  4. The application folder looks very similar to that for CI3, with some name changes, and some subfolders moved to the writable folder
  5. There is no longer a nested application/core folder

The application directory i.e. app is the source code of your application. All the stuff done by you will remain here. The default structure of the app directory is as :

/app

        /Config         Stores the configuration files

        /Controllers    Controllers determine the program flow

        /Database       Stores the database migrations and seeds files

        /Filters        Stores filter classes that can run before and after a controller

        /Helpers        Helpers store collections of standalone functions

        /Language       Multiple language support reads the language strings from here

        /Libraries      Useful classes that don’t fit in another category

        /Models         Models the database and business logic.

        /ThirdParty     ThirdParty libraries that can be used in application

        /Views          Views make up the HTML that is displayed to the client.

The above concepts will help you when you will doing any application on code igniter or you will be in CodeIgniter interview.

Spread the love

Jquery noConflict() Explained

What is noConflict() method in jQuery?
This is very important to differentiate scripts when we are using many JavaScript framework in our project.As we know jQuery uses dollar symbol ($) as shortcut. There are many other popular frameworks are there as Angular JS,Knockout JS,Kendo JS,Backbone JS,Ember ,Vue etc.
Suppose i one of these frameworks is using the $ symbol as shortcut then one of the scripts either jQuery or the framework implemented parallel may stop working. noConflict is a method to avoid such situation in script.

We can create our self defined symbol or string as shortcut for jQuery. noConflict() return a reference and we can store this reference in a variable.

Example of noConflict() and self defined shortcut:

var jq = $.noConflict();
jq(document).ready(function(){
    jq("button").click(function(){
        jq("p").text("Hi there,Conflict resolved");
    });
});
Spread the love

Hooks in CodeIgniter

In code igniter hooks are the points before and after the execution where we can call some specific functions.

These functions are called hooks and points where we call hooks are called hook points.

Hooks in Codeigniter are useful when we have to make some changes throughout the application, then we can do this without hacking all the files, just adding one hook at the appropriate point.

We can modify the way of usual rendering in code igniter application.

So hooks facilitate modification in functionality without changing the core.

Hooks in Codeigniter is important part of any Codeigniter Interview.

How we can use a hook in the Codeigniter framework?

Before we use any hook in application we need to enable the hook in config.php file. Set the enable_hook config variable: TRUE,

$config['enable_hooks'] = TRUE;

The Codeigniter framework provides the number of Hook Points to ease the development and modification in the application:

[1]pre_system:
The pre_system is called very early during system execution.

Only the benchmark and hooks class have been loaded at this point.

[2]pre_controller:
As per the name just called before any of your controllers being called.

When all the base classes are loaded, routing and security checks are done a pre_controller hook is called.

[3]post_controller_constructor:
The hook is called just after the controller class instantiated but none of the methods is called.

[4]post_controller:
Called immediately after your controller is fully executed.

[5]display_override:
We have the _display() function in our core and we use it to render our view on the browser after the execution of all programs.

display_override allows use to display our own content at desired places.

$this->CI => get_instance();
$this->CI->output->get_output();

[6]cache_override:
We can call our own function instead of _display_cache() function using the cache_override hook. We can define our own cache display mechanism.

[7]post_system:
At the end of the system execution when final rendering is done post_system is called.

Define a hook :
A hook is defined in the hooks.php file located at application/config

Example of define a pre_controller hook:

$hook['pre_controller'] = array(  
            'class' => 'Classname',  
            'function' => 'functionname',  
            'filename' => 'filename.php',  
            'filepath' => 'hooks',  
            'params' => array('element1', 'element2', 'element3')  
            );  

The Hooks in Codeigniter will boost your learning  Codeigniter.

Spread the love