Ihr Partner in Web-Entwicklung

Innovative Ideen für Ihr Unternehmen

Web-Entwicklung

Egal ob neue Firmen-Webseite, CRM-System oder Spezial-Software. Wir sind ihr Ansprechpartner in Sachen Web-Entwicklung!

Wir erstellen Webseiten und Web-Applikationen nach ihren Wünschen und Anforderungen. Dabei setzen wir stehts auf die neusten Technologie- und Sicherheits-Standards.

Netzwerk Administration

Planung, Aufbau und Administration ihres kleinen bis mittelständigen Firmen-Netzwerkes.

Wir kümmern uns daraum dass es in ihrer Firma läuft. Wir planen, bauen und administrieren ihr Unternehmens-Netzwerk.

Linux Server Management

Aufbau, Instandhaltung und Wartung ihres Linux-Servers.

Wir bieten ihnen einen umfassenden Service für ihren Linux-Server. Wir sorgen dafür, dass alles auf dem neusten Stand ist und ihre Services verlässlich laufen. Dabei achten wir stehts auf die Sicherheit ihres Netzwerkes und ihrer Kunden.

Wer Sind Wir?

Software ist Analyse und Instrospektion. Um einen Prozess zu verstehen, betrachten wir ihn so lange bis wir ihn verstehen. Gute Software erklärt einen Prozess in einfachen Schritten.

Wir bauen Software aus Micro-Services, kleine Komponenten die eine kleine Aufgabe erledigen. Ein Service alleine ist nahezu nutzlos, aber wenn mehrere zusammenfließen - dann können sie komplexe Prozesse abbilden und verwalten.

Viele unserer Services sind Open-Source, so das sie von der Community geprüft und verbessert werden können. Das erlaubt uns transparente und effiziente Arbeit.

Wir ergänzen diese Services dann mit anderen Services die proprietär sind, und das geistige Eigentum ihrer Firma schützen. [Mehr erfahren?]

Wir möchten das unsere Kunden das Gefühl haben das dass was wir tun ganz einfach ist. Dann wissen wir das wir es richtig machen.

César

César

Inhaber & Entwickler

Sebastian

Sebastian

Entwicker

BLOG

Wir nutzen unseren Blog um uns mit anderen Entwicklern auszutauschen. Die Softwareentwickler Community ist global, und selten Deutsch sprechend. Unsere Artikel sind deshalb alle auf Englisch verfasst. Wir laden sie trotzdem ein sich umzuschauen.

Sending emails in PHP via SMTP

13/12/2019

This week I got to the point where a small web-project, which I started a few weeks ago and isn’t based on any framework, needed the functionality to send emails. And since the build in mail() function in PHP is kind of garbage, I started with a quick web-search. The most popular and easiest way to achieve this is “PHPMailer”.

PHPMailer is a full-featured email creation and transfer class for PHP. It’s used by many open-source projects like: WordPress, Drupal, Joomla! Etc.

It’s very easy to use and supports all common standards like SMTP, HTML email, attachments, multiple recipients, CC, BCC and reply-to addresses. It even has support for localization with over 50 languages build in!

You can install PHPMailer via Composer or if you don’t use Composer (like me in my project) you can download it on their GitHub-page. The installation process is easy to understand documented on their docs and just takes a few seconds.

So if you a small or even bigger project with the need to send emails you should definitely checkout PHPMailer!


: 0 : programming, php, email

Exciting PHP 7.4 features pt. 3 - Throwing exceptions from __toString()

06/12/2019

This has probably been one of my most painful experiences with PHP since I started with PHP5.2 back in 2010.

Up until PHP 7.3, the magic __toString method on objects would prevent anyone from throwing an exception, instead throwing an error about the fact that you’re not supposed to do it.

Apparently, this comes from the way the toString method has been historically invoked. PHP used some internal magic to call these methods without a proper environment to throw an exception from.

This would lead to a code like this:


class Test { /* .. Some methods and properties ... */ public function __toString() { return $this->calculateValueThatThrowsExceptions(); } } echo new Test;

Causing an error about an exception that never got reported. When you find this error in the logs, it’s absolutely destructive - it has no debug traces, no stack, no information. It’s just a fatal error.

Instead you were left doing something like this:


class Test { /* .. Some methods and properties ... */ public function __toString() { try { return $this->calculateValueThatThrowsExceptions(); } catch (Exception$e) { ExceptionHandler::instance()->handle($e); die(); } } }

To prevent the exception from going unreported. This code though, is not SOLID, it’s extremely verbose, and makes the method unnecessarily hard to read.

Starting with PHP 7.4, we’re finally getting the chance to throw an exception from within toString without the need to build our own boilerplate around it.

This is one of the most beautiful features making it into PHP 7.4. There’s nothing that needs to be done to embrace it, and it scratches a very deep itch for me.


: 0 : programming, php, emailphp, engineering

Exciting PHP 7.4 features pt. 2 - Null coalesce assignment

30/11/2019

Read Part 1 - Arrow functions.

This is the change with the strangest name I’ve ever heard. But it’s a fantastic addition to PHP. It allows to set a value to a variable if the variable was either undefined or it’s value was null or false.

It’s based on a feature that was introduced “recently” in PHP 7 and that we talked about here: Testing the ?? operator.

The idea with the null coalesce operator (??) was that you can do something like this:


myFunction($variable?? 'Default value');

One of the most common uses for this, and one that we talked about in the post mentioned above, was that you can use it to create defaults for input variables like this:


$_GET['something'] = $_GET['something']?? 'default';

This allows this code to get even shorter, and reduce repetition:


$_GET['something']??= 'default';

A fantastic use for this would be writing an “extend” function in PHP because now you can use something like this:


function extend($a, $b) { foreach ($a as $k => &$v) { if (is_array($v)) { $v = extend($v, $b[$k]?? []); } else { $v = extend($v, $b[$k]?? null); } } return $a; }

: 0 : programming, php, emailphp, engineeringphp, engineering

Found somebody was trying to brute force my server

26/11/2019

I got a friendly reminder that you need to be cautious and hide your server’s SSH port from people trying to brute force it. So here’s a little checklist to make sure your server doesn’t get forced too:

  • Disable root login
  • Change the port from 22 to something random that makes it harder to find
  • Enabe something like fail2ban to prevent people from being able to force their way in
  • Disable password based login, or use a extremely long random password

If you’re asking yourself, are people trying to brute force it? Here’s some tips to recognize an attack:

  • /var/log/btmp is getting really huge, really fast
  • /var/log/auth.log is getting really huge, really fast too
  • If your server is publicly available, it’s probably being targeted

This should at least keep you safe from being exposed to those blanket attacks perfomed by botnets that try to infect other servers.


: 0 : programming, php, emailphp, engineeringphp, engineeringlinux

Exciting PHP 7.4 features pt. 1 - Arrow functions

22/11/2019

PHP 7.4 is around the corner, so I thought it’d be nice to talk about some of the most exciting features that await us for the last major release of PHP 7 before the new PHP 8.0 comes around the corner.

Many of us know arrow functions from Javascript, they basically are syntactical sugar for simple closures. For example, imagine this code where we have a collection of employees and wish to extract a list of employees from the IT department sorted by their salary:

$department = 'it';

$collection
  ->filter(function ($e) use ($department) { return $e->department === $department; })
  ->sort(function ($a, $b) { return $a->salary <=> $b->salary; });

With arrow functions it becomes something like this:

$department = 'it';

$collection
  ->filter(fn ($e) => $e->department === $department; )
  ->sort(fn ($a, $b) => $a->salary <=> $b->salary; );

You may have noticed that in the second piece of code I had no need to make use of the use keyword. This is because PHP will actually automatically include the scope of the parent block.

There’s a pitfall when trying to use these kinds of functions to modify a variable, for example, I’ve often used something like this:

$ids = collect([1, 2, 3]);
$models = [];

$ids->each(function ($e) use (&$models) { $models[] = db()->fetch($e); });

This code creates a list populated with models corresponding to the ids we have in the collection. But it relies on the code inside the closure to be able to modify $models. With arrow functions, this is not possible, so you’ll have to fall back to the regular method.

inb4 anyone notices. Yes, you could actually write this specific code like this:

$ids = collect([1, 2, 3]);
$models = $ids->each(fn ($e) => db()->fetch($e););

But I dare you to do the same with this:

$ids = collect([1, 2, 3]);
$even = $odd = [];

$ids->each(function ($e) use (&$even, &$odd) { ... });

Get’s trickier doesn’t it?

Anyway! This is a really exciting change, since it will probably shape a lot of the functional programming that is done with PHP. But, I honestly don’t expect to see this in the wild until well into the year 2020, since the savings are not too big, but any code written with this will be incompatible with PHP versions that are currently in the wild.


: 0 : programming, php, emailphp, engineeringphp, engineeringlinuxphp, engineering, programming

Kontakt

Wir haben Ihr Interesse geweckt oder Sie möchten uns einfach eine Frage stellen?
Gerne können Sie uns eine E-Mail verfassen oder sich telefonisch bei uns melden.

Wir freuen uns auf Ihre Anfrage!

Magic3W
Pelkovenstr. 148
80992 München