Alexander Cogneau – SitePointhttps://www.sitepoint.com
Learn CSS | HTML5 | JavaScript | Wordpress | Tutorials-Web Development | Reference | Books and MoreFri, 09 Dec 2016 14:00:17 +0000en-UShourly1https://wordpress.org/?v=4.4.2Personal Packagist with Toran Proxyhttps://www.sitepoint.com/personal-packagist-toran-proxy/
Fri, 05 Sep 2014 16:00:43 +0000http://www.sitepoint.com/?p=88798Most of you reading this already know Composer. For those who don’t, you can read a previous article of mine before contuing. We can all agree that Composer has brought many good things into the PHP world. If one dares however to look for drawbacks, or better put, not included features, he could state that it is not possible to work with private repositories. That argument won’t hold anymore, since there is Toran Proxy.

The end of the Satis era

Before Toran, those that really wanted to use private repositories, could use Satis. Satis enables you to generate a privately hosted Packagist website, with mirrored repositories and your own private repositories. It was compatible with private projects on bitbucket and github and guaranteed security by usage of SSH keys. By mirroring the packages you are using (hosting them on your own server) you will get faster download speeds. Satis was a fine solution but about a month ago Toran was released as a better alternative.

]]>Fractal: a Practical Walkthroughhttps://www.sitepoint.com/fractal-practical-walkthrough/
https://www.sitepoint.com/fractal-practical-walkthrough/#commentsMon, 04 Aug 2014 16:00:18 +0000http://www.sitepoint.com/?p=87007If you ever developed for an API, you might have had troubles with changes of your database schema. If you didn’t happen to have a good implementation, you had to rework your whole model when changing some column names. In this article I will demonstrate how you can use Fractal as a layer between your models and JSON output. This post will show you how this package will make API development easier.

Fractal as a package

Fractal is a project written in PHP, and part of The League of Extraordinary Packages. These packages all comply to several requirements, like usage of PHP-FIG and Unit Test coverage. Fractal is mainly developed by Phil Sturgeon and still receives regular improvements. It can also be used with Composer.

Setting up an environment

For demonstration purposes, I will now set up a framework using Silex and Illuminate/Database (the ORM component of Laravel). It doesn’t matter if you don’t have any experience with one of those. The things I will do are very straightforward and I will explain them as much as I can. If something is unclear do not hesitate to leave a comment.

I will now set up a framework. Note that if you don’t want to follow the steps, you can download all the code at the end of the article. Now start with creating a new folder inside root folder. We’ll start with creating our composer.json file, with all the dependencies that we need. In our case: Silex and Illuminate\Database. Create a composer.json file like this:

{
"require": {
"silex/silex": "~1.2",
"illuminate/database": "*"
},
}

Install the packages with composer install.

The database

I will take the example of an online music database. The database will provide information for several songs: the songname, the artist name, artist website, album name, release date and music label. In the beginning this will all be in one table. If you want to try it out yourself download the file 1.sql from this article’s repository and run it on your database.

]]>https://www.sitepoint.com/fractal-practical-walkthrough/feed/3Time Complexity of Algorithmshttps://www.sitepoint.com/time-complexity-algorithms/
https://www.sitepoint.com/time-complexity-algorithms/#commentsFri, 09 May 2014 16:00:02 +0000http://www.sitepoint.com/?p=80618If you are a web developer or a programmer in general, you have most likely written algorithms for various tasks. Examples are: searching through a table, sorting an array of numbers by descending value, calculating the shortest path to get to a location… But what qualifies an algorithm to be a good algorithm?

One specification of an algorithm is its correctness. You will probably assume that your algorithm works after testing it out a few times. However, if you can mathematically prove that your algorithm will work as expected for every input value possible, this is a huge bonus. I will not go further in to that subject in this writing.

Another specification is its efficiency: how does the computing time relate to the amount of input? Is it a linear relation? Does computing time rise exponentially for the doubling of input? That’s what this article will be about.

Time Complexity

Time complexity is, as mentioned above, the relation of computing time and the amount of input. This is usually about the size of an array or an object. Time complexity also isn’t useful for simple functions like fetching usernames from a database, concatenating strings or encrypting passwords. It is used more for sorting functions, recursive calculations and things which generally take more computing time.

This is not because we don’t care about that function’s execution time, but because the difference is negligible. We don’t care if it takes 10ms instead of 3ms to fetch a username. However, if we have a recursive sorting algorithm which takes 400ms and we can reduce that to 50ms, that would be an interesting thing to do.

As you might guess, the lower the computing time, the more efficient the algorithm is. The question that follows is: ‘how can we define time complexity in an universal way?’. That’s where we’ll use the ‘Big O notation’.

Big O notation

The Big O notation is a notation for the time complexity of an algorithm. It is a mathematical representation of the upper bound of the limit of the scaling factor of the algorithm. For example, if we double the size of an input array, by how much does the computing time increase? This might become clear with two examples:

]]>https://www.sitepoint.com/time-complexity-algorithms/feed/15Using cURL for Remote Requestshttps://www.sitepoint.com/using-curl-for-remote-requests/
https://www.sitepoint.com/using-curl-for-remote-requests/#commentsWed, 07 Aug 2013 14:30:08 +0000http://www.sitepoint.com/?p=6246If you need to make remote requests from your PHP scripts, cURL is a great tool for the job, and the PHP extension offers the same functionality as the console utility but in the comfortable world of PHP. This article explains how to use the cURL extension, discussing GET and POST requests, handling login cookies, and FTP.

]]>https://www.sitepoint.com/using-curl-for-remote-requests/feed/9PhalconPHP: Yet Another PHP Framework?https://www.sitepoint.com/phalconphp-yet-another-php-framework/
https://www.sitepoint.com/phalconphp-yet-another-php-framework/#commentsMon, 29 Jul 2013 14:30:24 +0000http://www.sitepoint.com/?p=6182From full-stack frameworks to micro frameworks, there's a wide offering of PHP frameworks to choose from. And they all claim to be special, too. But Phalcon really is quite different compared to the others! This article takes a brief look at what Phalcon looks like and what makes it so special.

]]>https://www.sitepoint.com/phalconphp-yet-another-php-framework/feed/22A First Look at Reacthttps://www.sitepoint.com/a-first-look-at-react/
https://www.sitepoint.com/a-first-look-at-react/#commentsMon, 25 Mar 2013 14:30:16 +0000http://www.sitepoint.com/?p=5385For the past couple of years, Node.js has been drawing increasing amounts of attention as a promising web technology. While it has some strengths, like being event driven, some people just want to stick to PHP. If you're one of them, you might want to take a look at a similar project for PHP named React.

]]>https://www.sitepoint.com/a-first-look-at-react/feed/5What’s New in Laravel 4https://www.sitepoint.com/whats-new-in-laravel-4/
https://www.sitepoint.com/whats-new-in-laravel-4/#commentsFri, 04 Jan 2013 14:30:41 +0000http://www.sitepoint.com/?p=4802The Laravel developers have been hard at work contributing some major improvements to the framework. Testability isn’t a problem any more, and neither is decoupling. Laravel 4 very well may be one of the greatest PHP frameworks currently available thanks to their hard work... so check out what's new!

]]>https://www.sitepoint.com/whats-new-in-laravel-4/feed/26Getting Started with Fuel CMS, Part 2https://www.sitepoint.com/getting-started-with-fuel-cms-2/
https://www.sitepoint.com/getting-started-with-fuel-cms-2/#commentsWed, 19 Dec 2012 14:30:26 +0000http://www.sitepoint.com/?p=4622Continuing to look at Fuel CMS, a lightweight and flexible alternative to heavier-platforms, this part of the series focuses on models and walks you through creating a simple Guestbook to introduce each aspect of working with them in Fuel CMS.

]]>https://www.sitepoint.com/getting-started-with-fuel-cms-2/feed/3Getting Started with Fuel CMS, Part 1https://www.sitepoint.com/getting-started-with-fuel-cms-1/
https://www.sitepoint.com/getting-started-with-fuel-cms-1/#commentsWed, 12 Dec 2012 14:30:09 +0000http://www.sitepoint.com/?p=4407When you hear the abbreviation CMS, you probably think about Drupal, Joomla, and even WordPress. However, there are alternatives to those heavy hitters if you want something more lightweight or flexible. If you're look a simple administration interface, or integrate custom application code into the site, then it might be worth your while to explore Fuel CMS. This part of the two-part series looks at Fuel CMS in general and how to create pages and views.

]]>https://www.sitepoint.com/getting-started-with-fuel-cms-1/feed/10PHP Dependency Management with Composerhttps://www.sitepoint.com/php-dependency-management-with-composer/
https://www.sitepoint.com/php-dependency-management-with-composer/#commentsWed, 14 Nov 2012 14:30:26 +0000http://www.sitepoint.com/?p=4295Maybe you've experienced the pain of working on a PHP application which uses third-party libraries and then trying to keep them and their dependencies up to date. If so, Composer can soothe your pain. It can get you the libraries you want at the versions you need. Dependency management can be a hassle-free experience using Composer!