Symfony

Dumping Object/Array Stacks in Symfony

Submitted by Peter Majmesku on Mon, 07/10/2017 - 13:54

I prefer using XDebug for debugging PHP code. But sometimes there's a huge nesting in the project, which makes the application very slow. Then XDebug can become pain. So there's an alternative for inspecting the contents of objects:

\Doctrine\Common\Util\Debug::dump($user);

It works for single objects and Doctrine collections and should prevent browser displaying issues you are having.

Debugging eMails in Symfony 2/3 and Drupal 7/8

Submitted by Peter Majmesku on Fri, 06/30/2017 - 22:33

The best tool for debugging eMails locally in my opinion is Mailcatcher. It catches all mails being sent via a specific port and shows them to you via an neat interface in your webbrowser. Firstly install Mailcatcher. It's programmed in Ruby and I could install it easily on Ubuntu and Mac. The instructions can be found at https://mailcatcher.me/.

Symfony 2/3

In the full stack edition it comes with symfony/swiftmailer-bundle. Make sure these settings are in your parameters.yml + parameters.yml.dist file.

mailer_transport: smtp
mailer_host: 127.0.0.1:1025
mailer_user: ~
mailer_password: ~

Afterwards you can send a test mail via the console:

bin/console swiftmailer:email:send

The mails will be shown to you like in the screenshot below.

The Mailcatcher Interface in Webbrowser

Drupal 7/8

Beside Drupal 8 install the "SMTP Authentication Support". You can find it's project webpage at https://www.drupal.org/project/smtp. Then visit the following page in your Drupal 8 instance: http://your-neat-webpage.dev/admin/config/system/smtp. Make sure the following settings are set in the config form (there's also a possibility to set them in the settings.php file).

SMTP server: 127.0.0.1
SMTP backup server: LEAVE BLANK
SMTP port: 1025
Use encrypted protocol: No

SMTP AUTHENTICATION: LEAVE USERNAME + PASSWORD BLANK

E-MAIL OPTIONS: ANY EMAIL AND FROM NAME

SEND TEST E-MAIL: ANY E-MAIL ADDRESS

Check "Enable debugging".

First part of settings form in Drupal 8
Second part of settings form in Drupal 8

Doctrine Query Builder: Filter Entity Types Based on Discriminator Column

Submitted by Peter Majmesku on Wed, 06/14/2017 - 09:36
<?php $queryBuilder $this->entityManager->createQueryBuilder()
            ->
select('mbt')
            ->
from('Bundle:MyBaseType''mbt');

        
$queryBuilder->where('mbt INSTANCE OF Bundle:SomeType'); 
Subscribe to Symfony