web development articles and portfolio

Articles and Posts with the tag "PHP"

Using Dependency Injection and IoC in Laravel 4 controllers

Using Dependency Injection and IoC in Laravel 4 controllers

I have never been a big framework user when it comes to PHP. While the language is not without its quirks and oddities that a good framework could help smooth over, I just never got around to really investing in a framework, as there is always a significant amount of initial effort needed to understand what the capabilities and limitations are, and whether or not it is truly suitable for a project. With that in mind, I typically just found it easier to write my own stuff.

PHP bcrypt hash a password with a logical salt

PHP bcrypt hash a password with a logical salt

As I write this opening paragraph, yet another high profile website has seen its collection of user data, including passwords, stolen by a successful hack - in this case I'm referring to LinkedIn.com (but if you're reading this well into the future, another name can probably be substituted here as the latest big victim). Unfortunately, if you're a big enough target, being a victim of a hacker is usually more a matter of "when" than "if", but lets not allow LinkedIn to get off that easy - those passwords I mentioned? Yeah, they were stored as SHA1 hashes - without salting (let alone per password salting).

PHP sessions stored in a Mongo database

PHP sessions stored in a Mongo database

When it comes to coding user based websites and web apps, one of the concepts you'll no doubt have to comprehend is handling user sessions. If you're using a server side language like PHP, session handling comes about fairly easily - simply declare a session_start() on every refresh, and store and retrieve values from the $_SESSION array. By default, PHP will read and write this session data using the filesystem, but what if you want to move this functionality to a database?

Custom PHP MVC Tutorial: Part 1, introduction

Custom PHP MVC Tutorial: Part 1, introduction

If you code your web sites/apps in ASP.NET or Ruby and you're in the market for a MVC framework, you don't have to look very far - ASP.NET MVC comes with the latest Visual Studio, and Ruby's resurgence in the land of web dev can largely be attributed to the trendy Ruby on Rails MVC framework. What about good ol' PHP, though? True to its open nature, PHP has a bunch of popular MVC frameworks to choose from, each with their own assortment of positives and negatives to consider. However, before you go off on an epic Googling quest to pick one, have you considered writing your own?

Custom PHP MVC Tutorial: Part 2, URL mapping and index.php

Custom PHP MVC Tutorial: Part 2, URL mapping and index.php

One of the universal characteristics seen in MVC frameworks across platforms and languages is the structure of the URLs that the site/app works on - http://domain/controller/action/id - which is what we'll roll with here too. To do this for our custom PHP MVC framework, we'll need to utilize .htaccess URL re-writing with Apache.

Custom PHP MVC Tutorial: Part 3, Controllers

Custom PHP MVC Tutorial: Part 3, Controllers

The controller classes in our custom MVC framework are the directors of our show. They get content from our models (writers?), and instruct our views (actors?) what to display. Even directors have orders to follow from above, however, and so do the controller classes in our MVC framework, in the form of a BaseController class they extend/inherit from.

Custom PHP MVC Tutorial: Part 4, Models

Custom PHP MVC Tutorial: Part 4, Models

In part 3, we discussed creating the controller classes, and the example used (the Home controller) to show how a controller class might look didn't seem to reference a model at all. Technically, the model in that example was inbuilt into the method of the controller - not ideal. In this part 4, I'll cover how you may go about improving on that design with a concept sometimes referred to as Skinny Controller, Fat Model.

Custom PHP MVC Tutorial: Part 5, Views

Custom PHP MVC Tutorial: Part 5, Views

When I first started to code websites in PHP, my understanding of separating PHP code from HTML consisted of complex string concatenation and a scary amount of character escaping. When I first started using MVC frameworks a little while back, it was like chocolate mud cake started to fall (safely) from the sky - my HTML finally looked like HTML, and not HTML murdered by server side coding syntax.

Custom PHP MVC Tutorial: Part 6, Where to now

Custom PHP MVC Tutorial: Part 6, Where to now

Through Parts 1 to 5 of this series of articles, I covered what MVC means at a basic level, why you may want to create your own MVC framework in PHP, how a basic framework might look from a design point of view, and then how this basic framework does look and work in more detailed breakdowns of all major components. In this Part 6, the final member of the series, I'll discuss how you might progress with this framework from some guy's Internet ramblings to something you put to practical use.

Portfolio entries with the tag "PHP"

groundwork Nathan MVC orderstarter perfmonUI RandomFury This Website TweakTown
RandomFury