PHPUnit with CodeIgniter 3 install

To PHPUnit with CodeIgniter 3 one required the extension to use CI-phpunit test the minimum PHP version 5.4 requires.

The latest version of PHPunit requires PHP 5.6, It should be therefore a possible current PHP version installed.

As can PHPUnit automatic installation routine running smooth.

Then you can be the application/test folder of the downloadable .zip archive of CI-phpunit test unpacked in the CodeIgniter project are. more…

Part 1: Clean Code – Rules for good, clean code

To write clean code and easy to understand the ultimate goal is a good IT Projet. Much depends on:

  • Maintainability
  • Training time for other programmers, means fast, what do individual functions
  • Robustness to changes
  • Testability, everything falls together, with small changes, can quickly stable updates are
  • Popularity with other programmers e.g.: bei Open Source Projekten, as a negative example is called XT-Commerce

The highly recommended standard work on the subject is “Clean Code – Refactoring, Patterns, Testing and techniques for clean code” of Robert C. Martin. In this article, chapter 1 to 3 treated.

Meaningful names

The name of a variable, Function or class should declare immediately, why you exist, what it does and how it is used. If a variable requires a Comment, It expresses not its purpose.

Bsp:

int d //Anzahl vergangener Tage
besser ist:
int daysSinceCreation;

Pronounceable name use

No constructs with unclear abbreviations as: int daSiCre instead of daysSinceCreation.

Searchable name use

Modern IDEs make searching easy, but it's no, when you have to look for the letters e and a control variable is swamped by results.

Variable names with a letter must only be used as local variables in short methods.

more…

$_GET Variables in CodeIgniter and SEO

CodeIgniter is a result of Sichheitsprobleme Get-variables this was moderately disabled, d.h. they will be overwritten when launching the website.

A possibility to use GET variables still while generating search engine friendly URLs is:

$this->uri->segment(3)

This command is called from a URL:http://www.foo.de/1/2/3/ the value 3 back.

The advantage is, that no name-value pairs in the URL are located more, but only the values, what shortens the length of the URL and very seo friendly. The disadvantage is, that the order may change, of course, and there is then problen.

RESTful Services in CodeIgniter und White Screen

To mount a RESTful service in CodeIgniter, one uses the very best of good libraryPhil Sturgeon, thanks a lot!

I unfortunately have to struggle with the White Screen of Death with CodeIgniter and found the following solution: The library in the latest version 2.4 1.7x does not work with CodeIgniter. It should be the version 2.2 install the library.

To check the, the version number of the file in CodeIgniter system/codeigniter/CodeIgniter.php found to be.

If the REST service is running, BTW you should change the following line in the REST_controller.php,so German umlauts and special characters correctly without error : Entity'ouml’ not defined usw. showing:

Line 693

$value = htmlspecialchars(html_entity_decode($value, ENT_QUOTES, 'UTF-8'), ENT_QUOTES, "UTF-8");

CodeIgniter debug with FirePHP

Codeignitor makes one that is not easy to debug, because in a normal printf or var_dump() Spending does not load the entire page and it only returns a server error. Therefore, the developer is forced, his project to debug properly, There are several possibilities:

  1. Logfile for
  2. use one of the above-named function, and then the()
  3. XDebug, But what is possible locally simply
  4. FirePHP for Firefox
  5. for Codeigniter Profiler

Installing FirePHP in Codeignitor is very good here described.

The debugging information should be output by the following code in the Firebug console:

$this->firephp->log('Message');

The very good Codeigniter Profiler can be enabled with the following command:

            $this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate");
            $this->output->set_header("Cache-Control: post-check=0, pre-check=0");
            $this->output->set_header("Pragma: no-cache");
            $this->output->enable_profiler(TRUE);