Why PHP Framework over CorePHP?

Don’t need to reinvent the wheel again and again.

This article is about explaining why you should insist your vendor or client to go with some inbuilt framework rather to go with Core PHP.

CorePHP-VS-PHPFrameworks

I will explain it via one real time example: Science Calculator

Now assume, you have one mathematical problem to solve. You have 2 options, 1. Pen / Paper 2. Science Calculator.

With option 1, brilliant student will solve the problem but poor will waste the time, get half of the solution, half of the accuracy and quite. This process will take time and more efforts to even by brilliant student.

With Option 2, almost everyone, who knows how to use calculator can achieve the task with accuracy of 75%-100%.

So if calculator is already created to solve the problem, why student has to start it from scratch, rather he can use calculator and use it to solve more complex problems. Here corePHP is blank paper given to solve problem whereas framework is calculator which is already build to do some core level things.

Client & Vendor

We as a software development company offers the same way as explained in example to our client. Variety of clients arrived with variety of requirement. We need to choose when, what, why, how straight based on requirement given.

When client comes to us with requirement of some business model which is not CMS or Ecommerce, we have to go with custom development. Custom development means, solution needs to be developed from scratch. But that doesn’t mean we have nothing in hand to start with. We can pick suitable framework which provides you structure, libraries, flow which is well tested and proven successful. These framework has nothing do with core business logic which is asked by clients but yes it has to do with technology we have choose for the system clients wants to build. And technology and its readymade library help us along the way to achieve our business model development

Here, I am, as a PHP experienced developer will describes you “Core PHP Vs. PHP MVC Framework”. There are other frameworks too like WordPress, Magento, Joomla, OpenCart, Drupal but this are for some specific purpose which can not fulfill the need of custom solutions.

Core PHP VS. PHP Framework

Core PHP: Core PHP is neither framework nor language. PHP is PHP. Core PHP term used for web applications developed using basic PHP which is been written from very scratch and do not consist of any library or extensions.

I mainly choose corePHP when web solution is easy, straight forward and small upto 4-8 easy web pages. Why? Core PHP having no structure, no library to use, no rules and restriction. Developer can write as he knows and as he wants. He himself defines the definition, flow, file/directory structure and even the way web pages render. Means, 5 developer have 5 different Minds working in 5 different ways 🙂 So, big problem for big application.

For small application of few pages, everything will be in front and hardly 1 developer will work so no mess we are expecting. Another disadvantage with core is, you will have no library and you have to get it from outside sources. Do not worry, you will get plenty for different purpose, but it gets complicated when people start writing it by their own way. There will be case, where one developer will write “How to review product?” in 10 lines of code, whereas developer 2 can take 100 lines of code to do the same. How and Who will stop them making it complex?

So corePHP is bad? No, not at all. Anybody who use framework should know PHP, Core PHP helps beginner to write code and understand it from ground. Once they know basics, they can move on. It’s bad when it goes to bad developer’s desk. We can not stop anybody thinking or playing in open ground as they want. Who and how we will watch them not doing right. So the best I can say is “Not to give developer an open ground, that’s it.”

Our target should be usage of PHP, as PHP is open source, light weight, affordable, user friendly, robust, advanced. So best benefits we can take of PHP is via MVC PHP frameworks.

So to conclude: Why Not to use?

  • Core PHP, is not structured in any standard way
  • Core PHP, having no libraries at all
  • Core PHP, is open ground without boundaries
  • Core PHP, having no enhancement strategies kept in mind from scratch unless and untill developer think on it from scratch and make one for this purpose. (Its depend on developer, but we can not expect every developer to be a very smart and highly knowledgeable person as there are bajillion of things out there in single PHP framework. )
  • Poor error handling.

MVC PHP Framework: MVC PHP Frameworks are structured and systematic packages created wisely by group of experienced PHP developers using PHP language only. Name a few, Laravel, CakePHP, Yii, Codeigniter a very famous these days.

Framework assures reliability, consistency and a big time-saver. It has a rich set of functionalities, so you do not need to reinvent the wheel again and again. It has almost all functionalities to build one medium to big sized, well behaved, scalable, robust PHP web application. Long list of functionalities/advantages I can write down,

  • Code and File Organization: Everything from your smallest item like css file to biggest and most important file like controller is at specific place.
  • OOPs: Object oriented programming involved grouping, reusability, inheritance, overriding, overloading, abstraction many more. Class are the highest level of entity in OOPs which holds everything systematically to flows information between different modules and tables.
  • Less Code & Faster Development: There is of course a learning curve for all PHP Frameworks. But once you get over this hump, you will enjoy the benefits of rapid application development. You will write less code, which means less time spent typing.
  • Enforcing of Good Coding Standards: Another benefit of using Framework is maintaining coding standard in an efficient manner. Coding conventions are a set of guidelines for a specific programming language that recommend programming style, practices and methods for each aspect of a piece of program written in this language. Using Framework makes it so much easier to code as you should.
  • Utilities and Libraries: PHP is a great language for web development and provides N number of tools and libraries. As everybody can guess, these frameworks contains a lot of libraries to make your job easier. All top PHP frameworks come list of Libraries and Helpers, that help you with:
    • Form Validation
    • SOAP/REST API
    • Caching Mechanism
    • Input/Output Filtering
    • Data Handle With JSON
    • Database Abstraction
    • Session and Cookie Handling
    • Email, Calendar, Pagination
  • Performance: Putting all aside, you can actually gain performance benefits by using a PHP framework. They come with tools that help you do caching, benchmarks, profiling etc. Modern frameworks are also great with dynamic loading, as they load code only as needed. Different page requests can load different amount of library code based on what needs to be used.
  • Enhancement: We surely know, client comes one day to us with list of functionality after completion or deployment of any web application as no system can be 100% perfect, there is always chances for improvements. 1000s of user use it, and usually come to client with their basic or important list of requirement, client always happy to listen them as they are most important for business, especially in SASS and ERP systems, users are the business giver. MVC gives easy enhancement as it is structured and well maintained by keeping enhancement in mind.
  • Reusability: Framework is like scientific calculator, very few can solve problem using pen/paper in 100% accuracy but almost all who knows how to use calculator can solve problem in 100% accuracy. Means, MVC uses OOPs which turn into your own library, which you can use later in any of the project.
  • Consistency: I love it most about MVC, everybody knows, where is my css, js, view, model, controller, library, language file. Everybody know, how to use language variable. Everybody know how to call any of the function in controller. So consistency in usage of its core object to placement of equal type of items. So, any new developer can quickly jump into project and almost can start working on new or old module by focusing on actual business logic rather getting confused on where/how.
  • Permalinks: Best benefits over these new age framework is to hide which technologies we are using. Almost all framework nowadays built such a way that they do not reveal web page extension like .html, .php etc.
  • MVC: Model contains only database transactions and functions, View contains only user interface, Controller contains an actual business logic and constraints. So full separation and management between all three major and important part of any web application. It becomes so easy to renovate or revamp web application anytime.
  • DB Models: Each framework has its own solid way of handling database which is the most crucial part. Security & Accessibility is become high responsibility for any web application owner. MVC framework introduces ORM and such model which take care of data by preventing SQL injection kind of malicious activities.
  • Security: With a framework, most of the work for code security can be done for you automatically. For example:
    • Central Authentication
    • Any value passed to database object gets filtered against SQL injection attacks
    • Central input validation and filtering
    • All HTML generating functions, such as form helpers and URL helpers filter the output automatically
    • Cross Site Request Forgery (CSRF) Protection
    • Session Management Security
    • Cross Site Scripting (XSS) Protection
    • Encrypting cookies automatically is only a matter of changing a config option and lot more.

Cons of using Framework PHP

To every positive thing, there are always negative things impacting on it. To get the mastery in PHP frameworks, a developer has to master the core PHP language. Codes, syntaxes, classes must be thoroughly known for the desired PHP frameworks. Much coding is involved, so complexity is bit high. People who are a novice or a fresher may not be able to cope up with this complexity.

If not choose wisely, small sized application will bear unnecessary cost of hosting space and maintainability.

Conclusion

To pen down, for a beginner acquainting knowledge from Core PHP is advisable and then mastering the PHP Framework for a robust and secure website.

“Which PHP Framework to use?” is as important as “Core PHP or PHP Framework?” question. Be wise picking up suitable framework which becomes angel but not evil to you. Stay tuned.

Leave a Reply

Your email address will not be published. Required fields are marked *