10 tools for PHP developers in Ubuntu 14.04

real_programmers
To convert your Ubuntu 14.04 into a powerhouse for software development for PHP, you need to install some developer tools from the rich set of available software packages. I have made a top 10 of my favorite developer tools.

1) Install Eclipse 3.8 as a complete IDE

Altough everybody I know prefers the JetBrains IDE’s, I am still a sucker for free (as in speech) software. I think Eclipse and the various distributions of Eclipse you can download are just as good, when properly configured.

sudo apt-get install eclipse

2) Install Geany 1.23 as a lightweight IDE

I also often find myself using a lightweight IDE. After using way too much “gedit” I have recently (re)discovered “Geany” and I feel it is perfect. With the following commands you install it with a good set of plugins.

sudo apt-get install geany geany-plugins

You can find some Geany color schemes on Github that are worth installing as well.

wget https://github.com/downloads/codebrainz/geany-themes/geany-themes-1.22.2.tar.bz2
tar -xvf geany-themes-1.22.2.tar.bz2
mkdir -p ~/.config/geany/colorschemes/
cp geany-themes-1.22.2/colorschemes/* ~/.config/geany/colorschemes/
rm -Rf geany-themes-1.22.2 geany-themes-1.22.2.tar.bz2

3) Install MariaDB 5.5

MariaDB is the replacement for MySQL now that Oracle has acquired it. This is comparable to the replacement of OpenOffice with LibreOffice after Oracle got their hands on it.

sudo apt-get install mariadb-server

4) Install PostgreSQL 9.3

PostgreSQL may be the most powerful database around.

With PostgreSQL 9.2, query results can be returned as JSON data types. Combined with the new PL/V8 Javascript and PL/Coffee database programming extensions, and the optional HStore key-value store, users can now utilize PostgreSQL like a “NoSQL” document database, while retaining PostgreSQL’s reliability, flexibility and performance. (source)

I feel you should always consider using it before choosing any “NoSQL” or “documents-based” database.

sudo apt-get install postgresql pgadmin3

Do not forget to set the root (postgres) password.

sudo -u postgres psql postgres
ALTER USER postgres WITH PASSWORD '<password>';
\q

5) Install Apache 2.4 + PHP 5.5 + modules

Install Apache and the default method (mod_php) to serve the new PHP 5.5.

sudo apt-get install apache2 libapache2-mod-php5

Install PHP 5 support for MariaDB and PostgreSQL.

sudo apt-get install php5-mysql php5-pgsql

Some PHP packages for Symfony development.

sudo apt-get install php5-intl php5-sqlite

PHP packages for cURL and XDebug.

sudo apt-get install php5-curl php5-xdebug

Optional PHP packages for creating images (GD), doing geolocalization on IP address (GeoIP), encryption and Redis/Memcache caches.

sudo apt-get install php5-gd php5-geoip php5-mcrypt php5-redis php5-memcache php5-memcached

Now enable mod_rewrite and restart Apache to make sure everything is loaded.

sudo a2enmod rewrite
sudo service apache2 restart

6) Install Adminer 4

PhpMyAdmin is a very popular web-based database management tool. Adminer is a drop in replacement that beats it on almost all points. You can install the latest version of Adminer using:

sudo mkdir /usr/share/adminer
sudo wget -O /usr/share/adminer/latest.php "http://www.adminer.org/latest.php"
sudo ln -s /usr/share/adminer/latest.php /usr/share/adminer/adminer.php
echo "Alias /adminer.php /usr/share/adminer/adminer.php" | sudo tee /etc/apache2/conf-available/adminer.conf
sudo a2enconf adminer
sudo service apache2 reload

Now go here to run it: http://localhost/adminer.php

In the future you can easily update Adminer using:

sudo wget -O /usr/share/adminer/latest.php "http://www.adminer.org/latest.php"

7) Install Git

Install the Git source code versioning system:

sudo apt-get install git

Check out this great Git cheat sheet.

8) Install some compilers and build tools

With the following commands you get most common compilers and build tools.

sudo apt-get install gcc build-essential libc6-dev autoconf automake

9) Install the Microsoft fonts

There are always people that rely on the standard Microsoft fonts (like Arial). Although this is bad practice and HTML5 allows you to embed fonts, still it may solve some problems to just install these:

sudo apt-get install ttf-mscorefonts-installer

10) Upgrade your Office experience

A developer also needs to read or write some documentation or specifications. Libreoffice Writer is IMHO better than the real thing (Microsoft Word).

sudo apt-get purge gnumeric abiword
sudo apt-get install libreoffice

Feedback?

Did we miss some really important package? Let us know in the comments.

New XFCE features in Xubuntu 14.04 Trusty Tahr

Great news: on April 17th, 2014 Xubuntu 14.04 Trusty Tahr was released! Should you upgrade right away or to wait. This is a tough question. I was still on Xubuntu 12.04, because that was the previous LTS. My strategy is to upgrade from LTS to LTS. This gives me serious improvements every upgrade, but only once every two years. Also I think that most production environments will not follow Ubuntu’s regular release schedule of two new versions per year. So with the Easter days off I decided to give Xubuntu 14.04 Trusty Tahr a shot. I noticed the following new XFCE features:

1) New XFCE start menu (Whiskermenu)

whisker

It sure looks pretty, but I cannot start the start menu with the (Windows) “start” key on my keyboard (called “Super” in Linux).

whisker_start

By adding the above highlighted line, it works as I expected. Now I can press the “start” key and start typing.

2) Snap-to-side window maximizing

This image from WindowSpace shows how Snap-to-side works:
snap-to-side-2
It also clearly explains how “Snap-to-corner” works:
snap-to-corners-2
To get “Snap-to-side” behavior to work properly in Xubuntu you may want to disable the highlighted checkbox:

snap-to-side

To get “Snap-to-corner” functionality working in Xubuntu you may actually have to wait a little. Both Alistair Buxton and Štěpán Dalecký have written patches for XFCE:

These may make it in a next release. It is a pity that XFCE does not support this yet. Maybe PyWO – Python Window Organizer is a good alternative to this. Or does anyone have another trick for this?

3) There is only one panel

By default, XFCE now only has one panel and it is on the top. It contains both the start button, the window buttons (for all open windows) and the clock and notification icons. Actually, the panel is just like the one in Windows XP, but instead of on the bottom it is on the top. I prefer to add a bottom panel that contain the window buttons and remove those from the top panel. This gives me the old and familiar “Gnome 2″ feeling and that makes me happy.

Instructions:

  • Right click the top panel
  • Choose: Panel – Panel Preferences
  • Press the green “+” to add “Panel 1″
  • Drag it to the bottom
  • Make the “Display” tab of “Panel 1″ equal to “Panel 0″
  • Add the “Show Desktop” and “Window Buttons” in the “Items” tab
  • Remove the “Window Buttons” from the “Items” tab in “Panel 0″

xfce_new_panel

Conclusion

I added a shortcut for the start menu, changed the way the window snapping works and added a second panel. With these small modifications on, I like XFCE in the new Xubuntu even better. If you want to highlight other new XFCE features, or have improvements on the ones above, then let us know using the comments.

PyCon 2014, full conference on YouTube

pycon2014-logo_sub

PyCon US 2014 is being held in Montreal and the conference was last weekend (April 11-13).

PyCon is the largest annual gathering for the community using and developing the open-source Python programming language.

For all of you that did no go, the full conference is available as 138 YouTube videos:

  1. Python Epiphanies
  2. Opening Statements – PyCon 2014 (2014/04/11)
  3. mrjob: Snakes on a Hadoop
  4. Mining Social Web APIs with IPython Notebook
  5. Lightning talks – Saturday morning
  6. How to formulate a (science) problem and analyze it using Python code
  7. Hands-on intro to Python for beginning programmers
  8. Getting Started with Django, a crash course
  9. Exploring Machine Learning with Scikit-learn
  10. Diving deeper into Machine Learning with Scikit-learn
  11. Descriptors and Metaclasses – Understanding and Using Python’s More Advanced Features
  12. 0 to 00111100 with web2py
  13. What Is Async, How Does It Work, And When Should I Use It?
  14. Twisted Mixing
  15. Turn Your Computer Into a Server
  16. The Young Coder: Let’s Learn Python
  17. The State of Crypto in Python
  18. The Python Pipeline: Why you should reach out to local teachers
  19. Teaching Python: To Infinity and Beyond
  20. TDD for web applications, from scratch
  21. Straightening Out AngularJS with Python
  22. So you want to be a full-stack developer? How to build a full-stack python
  23. Shiny, Let’s Be Bad Guys: Exploiting and Mitigating the Top 10
  24. Search 101: An Introduction to Information Retrieval
  25. Realtime predictive analytics using scikit-learn & RabbitMQ
  26. Python Scraping Showdown: A performance and accuracy review
  27. Python + Geographic Data = BFFs
  28. Python for Social Scientists
  29. Python 3/2 Web Development with Pyramid
  30. Puppet Modules: Apps for Ops
  31. PostgreSQL Proficiency for Python People
  32. Pickles are for Delis, not Software
  33. Lightning talks – Sunday morning
  34. Let’s Learn Twisted Python
  35. Kneel And Disconnect: Getting The Fastest Connection Out Of A Hostname
  36. Keynote – John Perry Barlow
  37. IPython in depth: high productivity interactive and parallel python
  38. Introduction to Web (and data!) Scraping with Python
  39. Introduction to SQLAlchemy
  40. Introduction to Regular Expressions
  41. Introduction to game programming
  42. Improving automated testing with py.test
  43. Import-ant Decisions
  44. How to Get Started with Machine Learning
  45. Hello Physical World: A Crash Course on the Internet of Things
  46. Hands-on with Pydata: how to build a minimal
  47. Getting Started with SaltStack
  48. Getting Hy on Python: How to implement a Lisp front-end to Python
  49. Generators: The Final Frontier
  50. For Lack of a Better Name(server): DNS Explained.
  51. Flask by Example
  52. Faster Python Programs through Optimization
  53. Fan-in and Fan-out: The crucial components of concurrency
  54. Enough Machine Learning to Make Hacker News Readable Again
  55. Dynamics and Control with Python
  56. Django for Web Designers and Front End Developers
  57. Distributed task processing using Celery
  58. Distributed Computing Is Hard, Lets Go Shopping
  59. Decorators: A Powerful Weapon in your Python Arsenal
  60. Data Wrangling for Kaggle Data Science Competitions — An etude
  61. Contribute with me! Getting started with open source development
  62. Computer science fundamentals for self-taught programmers
  63. Character encoding and Unicode in Python
  64. Castle Anthrax: Dungeon Generation Techniques
  65. Cache me if you can: memcached, caching patterns and best practices
  66. By Your Bootstraps: Porting Your Application to Python3
  67. Build your own PiDoorbell! – Learn Home Automation with Python
  68. Building and breaking a Python sandbox
  69. Blending art, technology, and light, Python for interactive and real time
  70. Beyond Defaults: Creating Polished Visualizations Using Matplotlib
  71. Bayesian statistics made simple
  72. Application Deployment State of the Onion
  73. Ansible – Python-Powered Radically Simple IT Automation
  74. An Introduction to Twisted
  75. All Your Ducks In A Row: Data Structures in the Standard Library and Beyond
  76. Advanced methods for creating decorators
  77. Writing RESTful web services with Flask
  78. Which messaging layer should you use if you want to build
  79. What is coming in Python packaging
  80. Upgrade your Web Development Toolchain
  81. Unit Testing Makes Your Code Better
  82. Track memory leaks in Python
  83. The Sorry State of SSL
  84. The Day of the EXE Is Upon Us
  85. Technical on-boarding, training, and mentoring.
  86. Subprocess to FFI: Memory, Performance, and Why You Shouldn’t Shell Out
  87. So You Want to Build an API?
  88. Software Engineering Research for Hackers: Bridging the Two Solitudes
  89. Software Carpentry: Lessons Learned
  90. Smart Dumpster: Employing Python to Report Real-Time Resource
  91. Set your code free: releasing and maintaining an open-source Python project
  92. See Docs Run. Run, Docs, Run!
  93. Sane schema migrations with Alembic and SQLAlchemy
  94. REST is not enough: Using Push Notifications to better support your mobile clients
  95. Quick Wins for Better Website Security
  96. Python packaging simplified, for end users, app developers
  97. Python in the Browser: Intro to Brython
  98. Pushing Python: Building a High Throughput, Low Latency System
  99. Programming an Autonomous 20 Foot Blimp with Python
  100. PostgreSQL is Web Scale (Really)
  101. Postgres Performance for Humans
  102. Performance Testing and Profiling: A Virtuous Cycle
  103. Outreach Program for Women: Lessons in Collaboration
  104. My big gay adventure. Making, releasing and selling an indie game made in python.
  105. Multi-factor Authentication – Possession Factors
  106. Localization Revisited
  107. Lightning talks – Sunday morning
  108. Lightning talks – Saturday evening
  109. Know Thy Neighbor: Scikit and the K-Nearest Neighbor Algorithm
  110. Keynote – Van Lindberg
  111. Keynote – Jessica McKellar
  112. Keynote – Guido Van Rossum
  113. Keynote – Fernando Perez
  114. It’s Dangerous to Go Alone: Battling the Invisible Monsters in Tech
  115. Introduction to SQLAlchemy Core
  116. Introduction to Docker
  117. In Depth PDB
  118. Hitchhikers Guide to Participating in Open Source
  119. Getting Started Testing
  120. Garbage Collection in Python
  121. Games for Science: Creating interactive psychology experiments
  122. Fast Python, Slow Python
  123. Farewell and Welcome Home: Python in Two Genders
  124. Django: The good parts
  125. Diving into Open Data with IPython Notebook & Pandas
  126. Discovering Python
  127. Developing Flask Extensions
  128. Designing Poetic APIs
  129. Designing Django’s Migrations
  130. Deliver Your Software In An Envelope
  131. Data intensive biology in the cloud: instrumenting ALL the things
  132. Closing address – PyCon 2014 (2014/04/13)
  133. Cheap Helicopters In My Living Room
  134. Building the App
  135. A Scenic Drive through the Django Request-Response Cycle
  136. Analyzing Rap Lyrics with Python
  137. Advanced techniques for Web functional testing
  138. 2D/3D graphics with Python on mobile platforms

Now you need some serious time off to view all that!

source: http://pyvideo.org/category/50/pycon-us-2014

PSR-0 and PSR-4 autoloading of classes in PHP

The PHP Framework Interop Group is about interoperability standards between frameworks so that code can be reused between projects. To facilitate this way of working there is “Composer” (a package manager) and “Packagist” (a package repository) made available. The SCM system used by the packages is mainly Git and the code repository resides most of the times on Github. Symfony2 is heavily using this system already. For class autoloading (the most important interoperability problem) the following standards apply:

The following PHP file can be put into the vendor directory (and required by your project) to do autoloading of classes:

class Loader
{
    protected static $parentPath = null;
    protected static $paths = null;
    protected static $nsChar = '\\';
    protected static $initialized = false;

    protected static function initialize()
    {
        if (static::$initialized) return;
        static::$initialized = true;
        static::$parentPath = __FILE__;
        for ($i=substr_count(get_class(), static::$nsChar);$i>=0;$i--) {
            static::$parentPath = dirname(static::$parentPath);
        }
        static::$paths = array();
        static::$files = array(__FILE__);
    }

    public static function register($path,$namespace) {
        if (!static::$initialized) static::initialize();
        static::$paths[$namespace] = trim($path,DIRECTORY_SEPARATOR);
    }

    public static function load($class) {
        if (class_exists($class,false)) return;
        if (!static::$initialized) static::initialize();

        foreach (static::$paths as $namespace => $path) {
            if (!$namespace || $namespace.static::$nsChar === substr($class, 0, strlen($namespace.static::$nsChar))) {

                $fileName = substr($class,strlen($namespace.static::$nsChar)-1);
                $fileName = str_replace(static::$nsChar, DIRECTORY_SEPARATOR, ltrim($fileName,static::$nsChar));
                $fileName = static::$parentPath.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$fileName.'.php';

                if (file_exists($fileName)) {
                  include $fileName;
                  return true;
                }
            }
        }
        return false;
    }
}

spl_autoload_register(array('Loader', 'load'));

If you clone the guzzle library into “vendor/guzzle” then you can use the snippet below to load the Loader class and register the library. After that you can just use the Guzzle Client class, because the Loader takes care of the autoloading.

require 'vendor/autoload.php';
Loader::register('guzzle','GuzzleHttp');
use GuzzleHttp\Client;
$client = new Client();
// do something with $client

Alternatively, you can also use the autoloading file generated by Composer. I recommend doing this in a production environment. Using Composer allows you to manage your dependencies and automatically update them when new versions are released. This post should show you how the autoloading mechanism works in PHP. It also shows you how to build your own standards compliant autoloading mechanism, something you probably only need when building your own PHP framework.

“The Expert” is Lauris Beinerts viral comedy sketch

“The Expert” is the title of the short comedy sketch Lauris Beinerts (Google+) posted a last week on his Youtube account. It went viral and is heading for half a million views in under seven days. It is about a “Funny business meeting illustrating how hard it is for an engineer to fit into the corporate world.” The video stars Orion Lee, James Marlowe, Abdiel LeRoy, Ewa Wojcik, and Tatjana Sendzimir, and is written & directed by Lauris Beinerts. It is based on a short story by Alexey Berezin titled “The Meeting” (in Russian) or translated by Google.

“I can do absolutely everything, I’m an expert!”

At LeaseWeb we understand…

At LeaseWeb we understand how hard it is for an expert to operate in the corporate world. So, if you have been in too many meetings like the one so well portrayed above, then you may want to take a look at our career offerings for engineers. Currently we are looking for:

  • Senior Engineer Virtualization and Storage
  • Hosting Engineer Virtualisation and Storage
  • Hosting Engineer Cloud
  • Software Engineer CDN
  • Software Engineer Cloud
  • Infrastructure Security Engineer
  • Infrastructure Engineer Cloud

We employ over 360 people in the Netherlands, Germany, the UK, and the US. Despite the company size, we try to keep things informal around the offices, with few layers of management. The members of the OCOM Group (LeaseWeb, EvoSwitch, FiberRing, DataXenter) hail from over 34 different nationalities, making English the language of choice.

Interested in working for us? Take a look at our careers website!