PHP? Frameworks?

Tmra

Programmer
Hi, 

Just a question that ive been wondering recently as im teaching myself Front End Web Design. 

For pet sites / web and text based online rpgs, it seems they are predominantly coded in PHP.

Do you code it solely in PHP (ignoring the DB element) or do you incorporate frameworks? 

Edit : Found a few of you use/d Laravel; so, do you find following a framework either or does it have its own set of problems? 

Thank you! 

 
Last edited by a moderator:
Pet games can be written in any language ie CryptoKitties is written using block chain, haha. I think most people use PHP because it's easy to learn and has weak data types and syntax structure like Javascript so there's a lot less ramping up than a strongly typed and highly opinionated and strongly formatted languages. If you're new to programming PHP is also popular with creating websites in general.

However, it's not the most current and trendy language anymore. The latest craze is Javascript and JS frameworks like Angular, React and Vue. You can also use HTML5 and their new canvas. Most people are then running a NodeJS backend.

As far as do you need a framework and which one should you use, that's an entirely personal question. It really depends on what you're trying to make and if a framework is a good fit for that, and why or why not. I would recommend if you think you need a framework that you research all the ones you're interested in and then make a pros and cons list for each one with respect for what you're trying to make. What might work well for one pet game may not work as well for another.

 
Last edited by a moderator:
One plus side to PHP as the language of choice is that is an easily accessible language, both in how it written (weak typing as @Design1online mentioned), and it's availability with most hosting providers.

Laravel is a well documented and relatively easy to get started framework written in PHP. It generally can be learned quickly to a great result, and it's community is strong. With resources such as Laracasts (tutorials and guides in video format), it just allows you to grasp it quicker.

What you use is a personal decision. That being said, every language/framework as it's usefulness and things it does well. Some make real time communication easier (Node for instance is great at this), while others are a lot easier for web. Your choice should be tempered by the language/framework community, learning resources, and availability in hosting when starting out.

For beginners who are getting started, PHP has an insane amount of learning resources available to get started, and is one of the most available languages in terms of hosting. Not so say other language don't have great ecosystems around them, but PHP's is one of the larger/popular ones.

 
Frameworks tend to have a little bit of a learning curve to start but for the most part provide waaaaay more additional functionality that is a huge help that makes up for the curve. I personally like Laravel as well, but I've use CodeIgnitor and Slim before as well. Frameworks usually help tackle the things that wrap your website and assist in supplementary functionality like securely handling form submissions, routing, authentication, template rendering and database interaction. 

If you start from scratch you can do things the way you want them, but to be honest unless you are a VERY savvy developer I wouldn't recommend it. Frameworks will also introduce you to higher level concepts that you may not come across by just building your app the way you want. 

As far as languages go... every programmer and developer has an opinion and bias. I've listened to dozens of industry leaders in web development who were in Ruby, .NET, JS, PHP and the basic consensus among them all is that language really comes down to your values as a developer and what you want in a development community. No language is perfect, and each one has trade offs. Building your website in whatever language you choose is unlikely to have any real consequence until it becomes a very large site anyway. 

However that's all typically server side code. For front end you want to be looking at HTML/CSS and Javascript fundamentals. CSS Grid is kind of the big thing right now in that realm. As you get more advanced you'll also want to learn about tools for asset management, and post/pre processor's for CSS like SASS/LESS.  

 
I am a full stack web developer PHP on the backend JS on the front end. I am stronger in PHP than JS, but have worked with both plenty. 

For me I definitely prefer a framework for the PHP portion, though if it's a js heavy site a framework would probably be helpful there too. 

I love having a framework. Unless I am designing a really small fairly static site then integrating a framework makes my job a lot easier and just more enjoyable too. It already has basic things built in such as routing (allows you to have web.com/page instead of web.com/page.php for a simple example), validation tools, built in ORM (object relational mapper, maps database to the php code), etc... Things that are necessary or good to have and that I don't really want to do myself. 

For framework choices I do love Laravel. Hard to explain, but it just looks nice and is enjoyable to work with. I especially love Eloquent it's ORM. I strongly prefer to work with it, it's name is an accruate description. It has a standalone package and I have taken advantage of that on numerous occassions. For Animal Acres, which is half of Fat Free Framework I ported in Eloquent as well. I tried to use Fat Frees ORM for a while, but it was just too clunky and I felt like I was constantly forgetting the exact syntax and having to reference the docs or my own code, which is just a pain. Eloquent for me just feels natural. For basic operations I can just code without referencing anything.

For yourself you may just have to try some and see what you think. It can be helpful to learn some basics before just jumping into to a framework though, just so you can differentiate between what is PHP and what is the framework. And just get a feel for things without as much added complication. 

For PHP there are definitely a lot of resources, this is pretty helpful. But do pay attention to the age of any resources you look at. My husband has been learning, and I had pulled a couple free courses for him, and they were just bad primarily because of the the age. The ecosystem has changed a lot, and PHP has improved a lot. You don't want to learn bad habits by learning from outdated resources.

 
For PHP there are definitely a lot of resources, this is pretty helpful. But do pay attention to the age of any resources you look at. My husband has been learning, and I had pulled a couple free courses for him, and they were just bad primarily because of the the age. The ecosystem has changed a lot, and PHP has improved a lot. You don't want to learn bad habits by learning from outdated resources.
Excellent point, it's hard to keep old blog posts up to date with the changes in the languages. I remember someone looked at an old article I wrote once and complained I was using addslashes/stripslashes instead of mysqli_real_escape_string. In older versions of PHP (gah this shows how old I am now, haha, I'm talking late php 2 and php 3) there was no other ways to prevent sql injections! Boy have the times changed, haha.

 
I would not recommend PHP, honestly. It’s becoming more and more archaic as time passes. As a language it is messy, confusing, and barely conforms to its own patterns. While, previously, PHP was the most widely accepted language for new (and especially self-taught) web developers, we’re past that. Resources are far too great for us to still be married to the language. One personal downside is that the security support of PHP is short-lived: both 5.6 and 7.0 will be losing theirs at the end of this year. If you decide to learn PHP, I recommend it not be the first language learned, as it is very loose in structure and will teach you bad habits and poor understanding of concepts (such as objects, which don’t actually exist in PHP, it is not an object-oriented language).

JavaScript and HTML5 are IN NO WAY a fad - they are more updated technologies intended to replace the old ones, since JavaScript just got a major syntax update with ES6 (2016, ES7 and ES8 changes were much smaller) and HTML5 brings in some wonderful new interactive and animatic aspects with a better canvas. Nobody is still teaching HTML4 or XHTML in any sort of classroom setting (post-secondary, at least). There’s no reason that these sorts of games shouldn’t be built with an offline-first ideal, and service workers are vastly superior to older styles of AJAX (which is asynchronous JavaScript paired with any other language, hence the x) such as the jquery library.

Don’t just google for resources and blog posts, look for free resources on websites that are selling some of their courses to some degree - it is guaranteed to be more recent, and will have some level of quality control that individuals’ blog posts will not. Udacity and Udemy are both highly recommended, but make sure to read reviews of the instructors on Udemy (and don’t buy a course for more than about $10 if you choose to pay for one, they are constantly on sale). Codecademy is a great resource for learning syntax, but do yourself a favor and read some materials about learning to program that are not language-specific. There’s much more to it than syntax.

Ultimately, it is a choice, but I always encourage new developers to adopt things that are driving the modern mobile web instead of jumping on technologies that are years outdated. Syntax’s comments on front end are all correct, though I wouldn’t call CSS grid a big thing “right now” so much as a newer aspect of CSS that pairs with Flexbox to make much more responsive designs than either can accomplish on their own.

 
Back
Top