Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I begin learning PHP Framework? [closed]

I have known PHP basics, functional programming for a long time before. But this year, in my 2nd semester I have learned Object-Oriented Programming with Java. So I want to apply my knowledge of OOP to PHP. But I find it very difficult to think of any decent utilization. It's not like in Java everything is an object. I see it easier to connect to database an old way, to write some simple functions for logging or registration, etc.

All those examples http://php.net/manual/en/language.oop5.php just gives me knowledge about syntax, not methodology of using it.

So I began to think. Maybe it's because I wanted to apply OOP without any Framework, and it's no use without it? If so - any Framework recommendations that are easy to learn?

like image 620
heroix Avatar asked Jun 06 '11 10:06

heroix


People also ask

Is PHP still worth learning 2022?

Most machine learning companies in Bangalore are continually upgrading the scripting language, its functionality, and performance, creating tools to support it, adding libraries, directories, and so on! So, unquestionably, PHP is still in the game in 2022, and probably there will be no such change in the coming years.

Is PHP still worth learning 2021?

Originally Answered: Is it worth learning PHP in 2021? Yes 100% php is becoming popular day by day because of different CMS. Today if you want to learn web development then php is the best language to start with because of its easy to learn and easy to deploy quality. Hope its helps.

Should I learn PHP as a beginner?

For beginner coders and those just diving into WordPress development, PHP is one of the best places you can start. It's a super simple and straightforward language, making it one of the best programming language to learn, so it's fairly easy to get into, and it makes up the backbone of online development.


2 Answers

OOP is a methodology used to organise your code into meaningful, reusable entities and it doesn't alone answer to the question of "how to best organize your code to create web applications".

Most of the web frameworks use Model-View-Controller architecture (MVC) along with OOP. In order to understand how web frameworks work, I suggest you to familiarize yourself with MVC as well (for a starting point, see "Coding Horror: Understanding Model-View-Controller")

Also, regardless of any frameworks, it is crucial to understand some basic concepts when creating web applications. At the minimum, familiarize yourself with how sessions work (http://www.php.net/manual/en/book.session.php), as well as how you can access databases (PDO for generic database connectivity, MySQL for MySQL-specific binding, etc.).

As for what web framework to choose, the options are plenty. Therefore consider the following pointers as informative:

  • Yii Framework has a pretty clean OOP-based design (http://www.yiiframework.com/)
  • Another popular object-oriented PHP framework is CakePHP (http://cakephp.org/)
  • For a more light-weight framework with less overhead, consider CodeIgniter (http://codeigniter.com/)
  • The de facto web framework for PHP is Zend (http://framework.zend.com/). Its huge, comprehensive, well-supported, but not always the perfect companion when travelling light.
  • Also note that if you organize your code according to MVC, you may find yourself most comfortable when not using any frameworks at all

Also note that unlike in Java, in PHP object-oriented features have been slowly added during its versions 4 and 5. Therefore, many web frameworks designed for earlier versions of PHP may not provide you as cleanly object-oriented design as you might want. Therefore when choosing a framework, consider whether you opt-in for backward-compatibility (PHP4 support) or are you seeking for a clean, object-oriented design in the framework (mostly PHP5 required).

like image 101
jsalonen Avatar answered Sep 19 '22 12:09

jsalonen


OOP has its usage outside of a framework, you cannot compare apples with oranges.

The most respectable frameworks out there are written in OOP. So try to use one such framework in order to see use cases of OOP, then learn from that framework (step through with a debugger and learn how the framework works from the inside).

I would recommend you two things, if you really want to become a pro:

  • Zend Framework - not easy to learn, but it will show you lost of things from the next point:
  • a book about design patterns - VERY VERY IMPORTANT

Regarding the databases: modern PHP code should use PDO.

The framework will only show you usages of design patterns and how to organize your code, so you'll develop a "common sense" for it.

After you've passed that point, you will be able to invent your own OOP-world, without a framework (if this really needs be, although a framework gives you the time to actually be innovative).

like image 30
Flavius Avatar answered Sep 22 '22 12:09

Flavius