Better (PHP) coding and spotting syntax errors with CodeLobster IDE editor

Written by - 0 comments

Published on - Listed in HTML PHP Coding

When developing and writing code, a code editor can be extremely helpful and save you a lot of time. Of course, you could even develop your code in a Shell terminal, using vim for example. But even though vim offers syntax highlighting, vim won't help you to analyze your code, reference to includes or spot errors (except errors in string declaration).

To cope with all these limitations, let's take a look at the code editor CodeLobster IDE, a free code editor supporting multiple languages but with a clear focus on Bootstrap HTML (HTML, CSS, JavaScript) and PHP.

Cross platform (multiple OS) support

One really neat fact is that CodeLobster can be installed on all major Operating Systems: Windows, macOS, and yes, Linux! A lot of other editors only support one operating system so this helps you keep the same application and therefore user interface no matter on what kind of platform you are working on.

As I'm on a Linux Mint 20.1 workstation, I downloaded the deb package from the CodeLobster download page and then installed the package. You can do this by either using the dpkg command or by opening the downloaded deb file with the GDebi Package Installer (which is part of Linux Mint).

The user interface

From far away, all the code editors kind of look the same. That's something good because it helps you to use different editors which may be better suited for a different coding language. Or because you just want to try out a new editor. The default user interface layout is split into 3 columns: 

  • Meta-Information about the code (such as list of classes, functions and variables) and the Explorer on the left side
  • The opened file itself in the middle
  • Helpful tools such as map on the right side

These columns can also be removed so that only the code is seen.

For large files such as the Python script check_esxi_hardware, the map is helpful to quickly navigate to a certain spot in the file.

However as you can see, there is no syntax highlighting in this case. This is, as mentioned above, because CodeLobster clearly focuses on Bootstrap HTML and PHP code.

Bootstrap / HTML / JavaScript

Opening a HTML page nicely shows the syntax, which helps to identify errors. 

HTML page in Codelobster

In this case I opened a file "slider.html" which I used for an older article (First steps with noUISlider: Integration into HTML forms and more examples). As noUISlider is written in JavaScript, CodeLobster also shows the JavaScript related variables and functions. This is a nice helper to quickly spot all variables which are defined or used somewhere in the document.

The preview tab below the code allows to quickly see a visual result from the code:

HTML page preview in Codelobster

PHP Coding

The biggest use-case (at least speaking for myself) is creating PHP code in CodeLobster.

Syntax Highlighting and Class View

Not only does the syntax highlighting help a lot writing code, there are also a lot of cool features (helper tools) embedded. 

As seen before with the JavaScript example, the PHP variables and functions are nicely listed in the "Class View" overview. Again this helps to quickly spot all the defined/used variables across the whole script.

A double-click on such a variable listed in the Class View, highlights all the occurrences of this variable. This is very helpful, for example when you need to replace a variable name and you need to find the variable in the document. Once you've replaced the variable with the new name, the variable automatically disappears from the Variables overview on the left side.

Auto-helper when writing code

Another cool feature is the immediate function description when hovering over it. For example when hovering with the mouse above the "unset" function, the description of this function shows up.

Explaining a php function

When typing in code, CodeLobster automatically adds (or suggests) the correct code format. For example defining a variable $var with a string value, the closing double-quote is automatically appended after the value. Or when using a PHP function, such as echo(), the brackets are automatically added, too! Even better, inside the echo function CodeLobster shows a list with the available variables to use. This helps to avoid typos which would cost time later on. See the following GIF to see how this works.

Spotting PHP errors

To save (troubleshooting) time, CodeLobster allows to integrate code validation. This means the PHP code is checked for errors and these errors are then highlighted. However this is not enabled by default and needs to be configured first.

Let's take the following PHP code as an example:

After the echo() function there is clearly a semicolon missing. However no error is showing up by default. Imagine a file with thousands of lines - finding this typo requires time.

To validate code, CodeLobster uses the PHP binary itself in the background. This means PHP needs to be installed on your workstation. On my Linux Mint, I used apt to install the PHP CLI:

ck@mintp ~ $ sudo apt-get install php-cli

Then the binary's path needs to used. You can use whereis to find the correct path for the php command:

ck@mintp ~ $ whereis php
php: /usr/bin/php7.4 /usr/bin/php /usr/lib/php /etc/php /usr/share/php7.4-json /usr/share/php7.4-common /usr/share/php7.4-readline /usr/share/php7.4-opcache /usr/share/man/man1/php.1.gz

In this case the path I'm interested in is /usr/bin/php7.4. Back in CodeLobster, this can be configured in Tools -> Preferences -> Code Analyzer. As this is a PHP 7.x binary, the path is added into the "Path to php 7 file" field:

Adding PHP binary to CodeLobster for code analysis

After saving this, CodeLobster now shows a yellow icon and below the code information of discovered errors:

PHP error detected in CodeLobster

Note that the Code Analyzer points to line 5 here but the actual error happens in line 3. This is because PHP itself only runs into the error when trying to run code AFTER the error.
The error message below the code clearly indicates that (after the echo), the keyword "if" was unexpected and that a semicolon or comma was expected.

Dark mode!

For many developers (me not included), a dark mode is a must for an editor. The design of the editor can be changed. Either just for the current session using View -> Visual Style or as a permanent setting in Tools -> Preferences -> Visual Styles.

CodeLobster in dark mode

In this example, the selected Visual Style was "Modern Dark".

Free version vs. commercial version

For many programmers the free version of CodeLobster will be enough. However the commercial version offers additional features, which are very helpful for (in particular) CMS developers. For example if you are a Wordpress developer, the commercial edition comes with a pack of pre-configured Wordpress-internal variables and functions (for example: wp_list_bookmarks() ).

Also other CMS sytems (such as Joomla) or PHP frameworks (such as Laravel or Symfony) are available.

After installing the free version, there is a 30-day free trial of the commercial version enabled. After the 30 day trial period, a license key needs to be bought and activated (Help -> Registration).

Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.