0 comments

How to Setup Docker for Your Symfony Project

As you probably know, I am a big Symfony fan 🙂 In the last few years I used Vagrant to set up my Symfony development environment more or less as described here. But we now have Docker and it’s time to move forward with a new setup. Docker containers are generally more lightweight than Vagrant virtual …

In Blog, PHP and Symfony

by Dragos Holban on September 18, 2017

0 comments

How to Get Nearby Locations from MySQL Database

If you have a MySQL table with locations (latitude and longitude columns) you can get a list of locations near a specific point using the following query:

In this query we have noted the latitude of the reference point with <latitude>, its longitude with <longitude> and the maximum distance to search for with <distance> …

In PHP and Symfony

by Dragos Holban on September 14, 2017

2 comments

Symfony OAuth Authentication for Your Mobile Application

Let’s say you built an API using Symfony and you need to access it from a mobile application using authenticated requests on behalf of your users. Here’s how to make this work using Symfony 2.8 and Doctrine. Install FOSOAuthServerBundle We will use the FOSOAuthServerBundle to implement this feature. Install it using the following command:

In Mobile Development, PHP and Symfony

by Dragos Holban on September 6, 2017

0 comments

Setup Docker Machine for Symfony Development

If you need a development environment for Symfony, hosted by Docker, you can use the fazy/apache-symfony docker image to start with, then extend it to your need. In your Symfony project’s folder add the Dockerfile and docker-compose.yml files. In the first one, we added mysql and composer, then we used the docker-compose.yml file to mount a …

In Blog, Development, PHP and Symfony

by Dragos Holban on April 27, 2017

testing and fixtures
1 comment

Setup Testing and Fixtures in Symfony2: The Easy Way

Setting up testing and fixtures in Symfony2 is vital if you plan on starting Test Driven Development or you simply want to start covering your code with properly written tests that can access mock data.   1. Install PHPUnit and php 5.6 The first thing you need to do is to install PHPUnit on your machine: …

In PHP and Symfony

by Sebastian Mihalache on March 11, 2016

0 comments

How to monitor Symfony and Apache logs with M/Monit

So you have developed and deployed a fresh new project and you want to be alerted in case an error happens. Here’s how you do it using the M/Monit tool. It can be installed on an Ubuntu machine using the following command:

Now edit the /etc/monit/monitrc configuration file and add the following:

First we need to tell …

In PHP and Symfony

by Dragos Holban on January 12, 2016

send emails in symfony2
7 comments

Send Emails in Symfony2: The Right Way

No matter what your app is about, at one you point you will have to send emails in Symfony2. Even though this process might seem straightforward and easy to apply, it can actually get pretty tricky. Here’s how you can send emails in Symfony2 by properly splitting your functionality and templates.   1. Mailer parameters …

In PHP and Symfony

by Sebastian Mihalache on December 2, 2015

12 comments

Symfony2 Facebook and Google Login: The Easy Way

Since pretty much any potential user of an app has a Facebook or a Google account, it’s crucial to have a login or registration service using these social networks. Luckily, HWIOAuthBundle provides the necessary tools to accomplish this. So here’s an easy and straightforward way to integrate HWIOAuth in our app alongside FOSUserBundle:   1. Configure HWIOauthBundle Assuming …

In PHP and Symfony

by Sebastian Mihalache on November 13, 2015

APIs in Symfony2
13 comments

Getting Started with Building APIs in Symfony2

Hello all you Interwebs friends! While we’re passing through the shallow mists of time, REST is becoming more and more of a universal standard when building web applications. That said, here’s a very brief tutorial on how to get started with building APIs in Symfony2. Spoiler alert: the bits of code written below use FosUserBundle + Doctrine. 1. Generate …

In PHP and Symfony

by Costi on November 3, 2015