developed.be | PHP Web Development

While jQuery is a great improvement on classic Javascript, it’s still not perfect. What works in version 1.3 doesn’t automatically work in 1.7 and what works in Firefox, doesn’t automatically work in IEx. The syntax isn’t very straightforward and some properties are misleading (eg: .val() vs .value())

This is an updated! incomplete list of stuff I need regularly that works in jQuery/javascript:

DOM Hierarchy

Get an ancestor

$("#element").parents(".these_ancestors")

Continue reading “The jQuery and Javascript code snippets you should learn by heart”…

  • Most fonts are located in /usr/share/fonts
  • But there isn’t just one folder. You can find the location of all the font folders in /etc/fonts/fonts.conf
  • You can save custom fonts in the folder ~/.fonts . It’s possible that the folder doesn’t exist, so you have to create it.
  • The filenames of some fonts are different from the actual fontname. Search in the directory for parts of the fontname. Eg: the “Monospace” font in Ubuntu is actually an alias for DejaVuSansMono and is called ttf-dejavumono.ttf
  • sans” or “sans serif” like Arial, is a font with no accents attached to the characters. (sans is French for “without”). Use for screens and websites.
  • serif“, like Times New Roman, is with accents attached to the characters. Use this for printing text or books.
  • mono” or “monospaced” like Courier New, is a font which characters are equally wide. Use this for coding and html.
  • To clear the font cache, like when you’ve downloaded a new font, use this command:
    sudo fc-cache -vf

 

This tutorial explains how to secure your Dropbox files with Truecrypt in Ubuntu (or Linux Mint). It assumes you know Truecrypt already and have a basic understanding of the Unix folderstructure.

Why securing your files in Dropbox?

I use Truecrypt for keeping my personal files. Basically all my important files are in a 50GB volume. My Dropbox folder was located inside the Truecrypt volume.

Like this:

/media/truecrypt1/Dropbox/all_my_files/

I wasn’t satisfied with the system. Who knows what happens with your data when you submit it to Dropbox. A hacker could get access to my account, or a Dropbox-employee or the government (not all stories are conspiracies).

There wasn’t really a point of securing my data with Truecrypt, when everything inside the Truecrypt-volume was copied to “the cloud”.

What even bugged me more were the credentials on my filesystem. Some folders need different credentials (www-root, root-owned files, mysql-files). When Dropbox faces a file it can’t access, it keeps on indexing and consuming cpu.

How does it work?

I came up with the following script:

Continue reading “Secure Dropbox by using Truecrypt volumes”…

I’m getting back at the PHP Laravel framework. I studied most of its documentation and have a decent idea what it can do.

However, I’ve reached at a point where I need a decent “imagecache” functionality, like you have in Drupal. There’s an attempt in Laravel but it doesn’t come close to the easiness of imagecache (probably one of the best Drupal modules).

Further down the road I must have some permission-system, user forms, a comment tool system, Mollom protection, Captcha’s, forgotten-password-mails, newsletter forms, node locking, search integration, OpenGraph, social media toolbars, permalinks and a zillion other features.

The thing is: do I have to reinvent the wheel? Do I even want to do that?

How much time does it take to make a light version of imagecache? If it’s done in half a day it might be worth it. The powerful thing is that I have total control about every little detail. Gone are the days that you can’t get around something because that’s the way it goes in Drupal (eg: must every node-type have a body-field?)

Can I make an opensource CRM/CMS based on Laravel? Ready for others? Is anybody waiting for that?

(for those wondering if I’m wasting someone else’s money, I spend most of my research in my spare time)

Update: I decided to go for it. Things go pretty well so far but, like any IT-project, it’s a lot of work.

That’s cool ey, making websites! Think twice! And if you’re planning to make a career-switch to webdeveloper, consider what you need to know before you can call yourself a webdeveloper. I started this list 5 days ago and new things still pop-up in my head.

Edit: update april 2017. I wrote this post 4 years ago. Things have changed of course. I added some stuff that you now need to know _as well_.

To kick off, you need to know:

  • HTML, well obviously. But there isn’t just HTML there’s also:
    • XHTML
    • HTML5 (please don’t tell me you don’t use <article>)
    • HTML for IE
    • HTML for everything but IE
    • Word HTML ®
    • Any DOCTYPE variation and their behaviours
  • Even if you’re not a frontend-dev you at least need to know some:
    • javascript
    • jQuery
    • jQuery-libs (version 1.7 of course not compatible with 1.3)
    • CSS
    • CSS 3
    • CSS for IE
    • JS Frameworks! Hurray! There’s Bower, grunt, node and other new kids on the block.
      • All you need to do is node install  (so they say)
  • Basic Photoshop knowledge (you will need to alter images some time)
  • Know all about usability
  • But we haven’t talked about the actual specialty: programming!
    • All basic program structures (sequences, iterations, classes, inheritance)
    • Keep CPU, disk iops and RAM in mind. Performance is very important.
    • A handful of design patterns
    • And of course some UML or other analysis tools
    • You shouldn’t, shall never and won’t use any goto’s
    • You must master the tools you have to program with.
    • Separate concerns
    • You are able to arrange cultural settings (the current time is: Mercredi octobre 19 22:05:12:4854 +05:00 GMT with daylight saving time)
    • Know regular expressions and how they don’t behave the same in every language.
    • Character encoding (UTF8, ascii, Unicode, Latin-types, url-encoding, html-encoding)
    • Encryption algorithms
    • Refactoring “a monster”.

Continue reading “What you need to know to be a webdeveloper, and how crazy you must be”…

To be honest, I’m a bit fed up with Drupal lately. We’re stuck with an ever-growing fat Drupal6 site, and the monster doesn’t get easier to maintain. The question isn’t if we will upgrade, but to what we will upgrade. The logical upgrade to Drupal7 will be enormous because our website has over 150.000 lines of custom php-code (not mentioning css, js, themes). So moving to Drupal 7 or creating something entirely new based on a framework… I don’t dare to say how much difference in time it will make, but I do know that the new thing must be a giant step forward to what we have now.

Why moving from Drupal to a Framework?

As much as I love Drupal, the thing is… a lot of modules do kind of what I want, but they don’t do exactly what I want. Customizing a contributed module sometimes takes me as long as I would write it myself. Especially when there’s little info in the README-file or when there are hardly any comments in the code. To give you an exampe: it’s faster to lookup the url for the admin-page in the menu-hook, than to find it in the documentation or in the navigation.

Plus, what irritates me the most. When you have +75 modules, +100.000 nodes and +10 currently logged in users, the thing gets slow.. slooowww! Even with advanced caching tools such as Memcached,  view-cache or Varnish, the thing still goes slow, even on a dedicated server. No wonder: every hook is checked for each and every request.

So I’m looking for something faster and more OO-like. I have a C#-background and the way classes are mimicked in php (including inheritance, namespaces) is simply terrible. I’d dare to say Drupal goodbye, as long as Drupal 8 isn’t released an is more decent.

My comparison of PHP Frameworks

Pfhew, long introduction, but here’s my research on PHP-Frameworks. Briefly, a framework provides a set of functions and classes to help developers write code faster and more structured. Most of them implement certain design patters, of which MVC is by far the most popular. The aim of MVC is to seperate the database-talking-code (Model) from application-specific code (Controller) from html (View). It also features a URL-mapping system to set “clean url”-rules and to separate the code-files from the actual urls (eg: /bootstrap.php shouldn’t be accessible through a browser).

Some devs use the bootstrap of a CMS as a framework-starter (like my RSS-boostrap), but it should actually be the other way around: a CMS should be build on a framework. Drupal8 will (maybe) rely on parts of Symfony2, but that won’t be out till 2014.

Continue reading “PHP Frameworks, which to choose in 2013? A comparison.”…

  • Published:May 23rd, 2013
  • Category:Drupal 8

Everything! Really!

Drupal 8 changes for developers

Everything will change and certainly for developers

  • The code will be more object oriented,
  • there will be a Symfony-like approach of theming (say goodbye to the _theme() hooks),
  • migrating from local to staging or a live-environment will be easier, as you will be able to save certain local settings in the code,
  • there’s the development project WSCCI (pronounced “Whiskey”) that will give devs the opportunity to write output for json, for apps, or for anything else besides html,
  • the multi-language-approach will be more logical and out of the box (Europe sighs).

In short… you probably won’t be able to reuse a single line of code from Drupal 7 to Drupal 8.

If you want to learn Drupal from scratch, you might want to wait till the release of 8 before you start to study.

Changes for users

For the users the changes are less dramatic, but there’s one big new feature:

  • In-place-editing, found in almost every commercial CMS will finally come to Drupal. This means that when you want to edit a text on a page, you don’t have to press the edit button, find the right field and save, but instead you’ll be able to change text within the normal website layout.

Still a lot of work

But… there’s still a lot of work. Drupal 8 is far from ready. The official release is planned towards the end of 2013, but the date march 2014 is probably more realistic. The in-place-editing for example is currently not working for the title-field, because the title is technically not a field. WSCCI is also far from ready.

Things are even so not-ready that some new features might be cut.

Download/contribute

Those who want to contribute or want a sneak preview, can install D8 through GIT. Though, it’s not stable, not even in beta, so don’t use it in a live-environment.

$ git clone --branch 8.x http://git.drupal.org/project/drupal.git

Like previous years DeWereldMorgen.be organizes an Ubuntu Install Party. Be present Sunday May 25th in De Vooruit. All details.

I upgraded my Ubuntu 10.04 to Linux Mint 14. After installing LAMP I got a Drupal WSOD on a previously well working site. As it turned out most errors came from deprecated php-functions and deprecated call by references to functions, introduced with the release of PHP 5.4.

At first I was a somewhat encouraged to solve those deprecated functions, but I gave up pretty soon. Drupal 6 isn’t designed for 5.4. Tweaking Drupal feels the same as upgrading to Drupal 7. Therefor, I keep it to PHP 5.3.

To downgrade 5.4 to 5.3 I recommend this script on the Ubuntu forums.

When installing the combo php5-fpm together with Nginx or Apache, you might run into this error:

[error] 4942#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: example.com, request: “GET /phpinfo.php HTTP/1.1”, upstream: “fastcgi://127.0.0.1:9000”, host: “example.com:80”

This is actually not an nginx error but a php-error. Nginx tries to contact php5-fpm, but fails in doing so. This is because it’s probably not running, or because the configuration is wrong.

Check if it’s running

To troubleshoot this, test if fpm listens on 9000. You can do this with telnet.

telnet 127.0.0.1 9000

Alternatively:

sudo netstat -tlpn | grep :9000

Telnet should return “Connected to 127.0.0.1”

Netstat should return a line starting with “tcp” and ending with “LISTEN”

Troubleshoot

If it doesn’t return anything or if it returns an error, it’s because fpm is not listening on port 9000. To solve this:

sudo gedit /etc/php5/fpm/pool.d edit

edit the line that says “listen = ” to:

listen = 9000

Then restart fpm:

sudo /etc/init.d/php5-fpm restart

You don’t even have to restart apache or nginx. It should work right away.

« Previous PageNext Page »