Symfony Forms

Quick Review: Creating a form in Symfony 5

Creating a form in Symfony 5 is a very simple process, just follow my instructions below. I will guide you in replacing the HTML form we used on our Symfony 4 CRM project.

If you have any questions please do let me know.

  1. Let’s make sure you have the required files on your project, run the following composer command
    1. composer require symfony/form
  2. Now let’s use the built-in template system to create our form
    1. php bin/console make:form
    2. Complete the requested information, I called it NewCustomer and bounded it to our previously created Customer model class.
  3. You can find the new form that was created at:
    1. App\Form\NewCustomerType;
    2. Open the file and review it, it should have all of the model class properties
  4. Change your new customer route to the following:
    1. $customer = new Customer();
      $formNewCustomer = $this->createForm(NewCustomerType::class, $customer, [
      ‘action’ => $this->generateUrl(‘addCustomer’),’method’ => ‘POST’,
      return $this->render(‘customer_manager/newCustomer.html.twig’, [
      ‘form’ => $formNewCustomer->createView(),
    2. This will tell your controller to generate a new form using the NewCustomerType form class that was generated previously. We are as well telling the system that it is a POST form that will go to the ‘addCustomer’ route once submitted. Finally, we are creating the form view and passing it to the TWIG template file.
  5. Go to your twig template file and remove your old form, add the following command
    1. {{ form(form) }}
    2. Just like that, refresh your new customer route page and make sure that the new form is showing.
  6. This is one of the most basic ways to add a Symfony Form to your application. Don’t forget it stills needs to be styled and most importantly, you need to code in a submit button at your NewCustomerType form class.
Symfony CRM - Let's Add Customers

Symfony CRM – Let’s Add Customers

This is the second part of our custom CRM. Last article we learned how to set up the application. We will now start with our customer manager controller.

Here are the steps

  1. Create a new controller
    1. php bin/console make:controller mainController

  2. Let’s create a basic menu on our application that will allow us to navigate the site
    1. A simple unordered list should suffice, I made one float to the left with the main content on the right side
  3. Add a link so that we can create a new customer, on your Customer Controller add the following code to add another route
    1. /**
      * @Route(“/customer-manager/new-customer”, name=”newCustomer”)
      return$this->render(‘customer_manager/newCustomer.html.twig’, [
      ‘controller_name’ => ‘CustomerManagerController’,
    2. Make sure to add this before your index route for proper redirection
  4. Create a new TWIG file at
    1. templates/customer_manager/newCustomer.html.twig

  5. Let’s start working now on connecting to our database, lets install the required files by running
    1. composer require symfony/orm-pack

    2. composer require –dev symfony/maker-bundle

  6. Set up your database connection information at your .env file
  7. Run the following command to set up your database
    1. php bin/console doctrine:database:create

  8. Now lets create an entity on the database
    1. php bin/console make:entity

  9. Now you have a file at
    1. src/Entity/Customer.php
  10. Run the following command to complete the database migration
    1. php bin/console doctrine:migrations:migrate

  11. Now lets create a way to add customers to your database
    1. Start by creating a new route where your form will be submitted to
      1. Example: /customer-manager/add-customer
    2. Here is an example code to add a new customer to try the connection
      1. use Doctrine\ORM\EntityManagerInterface;
        use Symfony\Component\HttpFoundation\Response;
        use App\Entity\Customer;
      2. /**
        * @Route(“/customer-manager/add-customer”, name=”addCustomer”)
        public functioncreateProduct(): Response
        // you can fetch the EntityManager via $this->getDoctrine()
        // or you can add an argument to the action: createProduct(EntityManagerInterface $entityManager)
        $entityManager = $this->getDoctrine()->getManager();
        $customer = newCustomer();
        $customer->setFullName(‘Glberto Cortez’);
        $customer->setPhone(‘(619) 339 9309’);
        $objDateTime = newDateTime(‘NOW’);
        // tell Doctrine you want to (eventually) save the Product (no queries yet)
        // actually executes the queries (i.e. the INSERT query)
        returnnewResponse(‘Saved new product with id ‘.$customer->getId());
    3. You should get the customer id back if it was successful
  12. Now let’s create a new route so that we can retrieve specific customer information. Let’s try by retrieving the name of the last customer we added, here is the code:
    1. /**
      * @Route(“/customer/{customerID}”, name=”showCustomer”)
      $customer = $this->getDoctrine()
      if (!$customer) {
      ‘No product found for id ‘.$customerID
      returnnewResponse(‘Check out this great customer ‘.$customer->getFullName());
      // or render a template
      // in the template, print things with {{ }}
      // return $this->render(‘customer/customer.html.twig’, [‘customer’ => $customer]);
  13. Now just create a new form on your New Customer route that was previously created and submit it to the Add Customer route. Update the code to store the submitted information to:
    1. use Symfony\Component\HttpFoundation\Request;
    2. $request = Request::createFromGlobals();
      // you can fetch the EntityManager via $this->getDoctrine()
      // or you can add an argument to the action: createCustomer(EntityManagerInterface $entityManager)
      $entityManager = $this->getDoctrine()->getManager();
      $customer = newCustomer();
      $customer->setFullName( $request->get(‘customerFullName’) );
      $customer->setEMail( $request->get(‘customerPhone’) );
      $customer->setPhone( $request->get(‘customerEmail’) );
      $customer->setEid( $request->get(‘customerExternalId’) );
      $objDateTime = newDateTime(‘NOW’);
      // tell Doctrine you want to (eventually) save the Product (no queries yet)
      // actually executes the queries (i.e. the INSERT query)
      returnnewResponse(‘Saved new product with id ‘.$customer->getId());
  14. Now you are able to create new customers, add some CSS styling and you have the first piece of your customer relationship management application.

Let me know if this article helped you or if you have any questions. As well for any PHP, Symfony, MySQL JavaScript, React or other web project make sure to contact us so that we can help you with the development.


Starting a custom CRM with Symfony 5

These are some of my notes on how to create a custom client-relationship manager (CRM) with Symfony5. I hope that this assists you in making a better project, let me know if you know of any better way to achieve this.

This is the steps to follow, which do not only work just for this type of application but for most full-size web applications built with Symfony 5:

  1. Download and install Symfony5 from
  2. Start a new project with the following command
    1. symfony new crm –full

      1. Where crm is the project name
  3. Make sure it loads properly by starting the development server
    1. symfony serve -d

      1. If the command it’s successful it will provide you the HTTPS URL where the server is loaded onto
  4. Create a new default controller for the application
    1. php bin/console make:controller mainController

      1. You can use the following command to obtain a list of things that you can easily do via you CLI
        1. php bin/console list
  5. Open your new controller using your editor of preference to edit the new controller, in this, you will see the default code. The location will be
    1. src/Controller/MainController

  6. Start by changing the route URL to “/” and refreshing your development server. It should now show the new home page from the MainController
  7. Let’s install WebPack into our application by running
    1. composer require webpack-encore

    2. yarn install

  8. Let’s execute WebPack by running
    1. yarn watch

      1. It is very important you install webpack-encore before any other yarn dependency. Failure to do so will result in an error and in a problem when running the command
  9. After the build it’s complete, we can then add what will be our JavaScript and CSS main files it onto our main template file
    1. We do this by opening our base TWIG template file saved at
      1. templates/base.html.twig

    2. Then we add the following
      1. Into the stylesheets, block add
        1. {{ encore_entry_link_tags(‘app’) }}

      2. Into the JavaScript, block add
        1. {{ encore_entry_script_tags(‘app’) }}

    3. Once added refresh your app, you should see now a Gray background. If you check your console you should see a log with a message “Hello Webpack Encore!”
  10. Now let’s install Bootstrap so that we can give your application a better shell to be displayed in
    1. yarn add bootstrap –dev

  11. After it is installed, we need to add the following line into the top our CSS main file located at “assets/css/app.css”
    1. @import “~bootstrap”;

      1. If you refresh your application, you will notice the change in font size and style


This is how I would properly set up initially a Symfony5 CRM application. I hope it helps you, more lists are to follow to assist you in building your project.

Bot Filtering Setting in Google Analytics

A common problem when working with modern sites and tracking them is that there are certain bots and spiders that trigger false hits. Many users seem to be experiencing a similar issue with bots and trying to get and analyze only real traffic. In order to resolve this situation Google has added an option to your View Settings -> Report View Settings which allows you to exclude all hit from known bots. The check mark is located on the bottom area of the setting under the label “Exclude all hits from known bots and spiders”. After this option is selected all hits by IAB know bots and spiders will be excluded by the back end of the Google Analytics platform.

This will give you a real number of visitors on your site. Nestle is one of the companies that started testing it due to some issues they were having and the answer has been very positive. It’s team called it “essential to getting a deeper insight”. We will work with it and give you an update on how this new change allows us to provide you with a better service.

You can view the official post along with others from the Google Analytics+ Account

Are you and your business Yelping?

In the past years the influence created by social media portals across the web on businesses and customers alike is huge and it is only getting bigger. One of the biggest influencers on this growing frenzy is Yelp, a social portal that gives customers/visitors the ability to give any business a rating and review based on a previous experience with the business. Visitors of the portal as well can search for businesses, services and/or products they are thinking of acquiring. With over 4 million visitors per day it’s a great place to gain visibility, however if not maintained it can also be something that can hurt your authority and ability to sale greatly. We have seen for some of our customers that up to 70% of their sales are directly affected by this portal.

When correctly utilized and optimized Yelp can definitively be a tool that can increase your revenue exponentially in a relatively small period of time if used correctly. However, to begin you will have to first and foremost confirm your listing or create a new one using their Business Center. After confirming your listing it is very important to go over each of the sections on your listing and complete them as thoroughly as possible. Get creative as customers are usually looking for someone that they relate to, give them your full story and allow them to meet you even before they contact you. Take advantage of their multimedia tools like adding photos and videos as customers are much more likely to respond if you do. Another very important factor of having a successful listing is staying in constant contact with you customers and to make sure that all of their reviews are answered.

A great and useful tool that they offer for free is the ability to add coupons for your customers. Many times this will increase your conversion rate, and it might just give you that edge as well that you need to beat your local competitor. Another great tool they offer for free is their listing statistics, which are very complete including how many visitors have seen your listing, how many have called your business number and how many have clicked to go into your website.

There are other ways as well in which Yelp can indirectly assist you to get more customers which is by increasing your overall business inline authority. This will assist you in many ways, for example to get better rankings in the different search engines across the web. The majority of times your listing will be listed as well usually higher than any other citations on the SERP’s, this will assist you to create more a more reliable image as they will see your name multiple times one the results.

Let us know how Yelp has affected your business, and what actions you are taking to improve the quality of your listing on the comment section below.

Lesson 1: Introduction to Search Engine Optimization (SEO)

SEO or Search Engine Optimization is the process of optimizing a web page or portal for search engines. ξPeople are now spending 7 times more time on the Internet than on watching TV, what does this tell us as marketers. It tells us that we need to focus into online marketing, in which SEO is a major player. There are four major engines currentlyy on the market. The most important and complex of them is Google, by a far reach.

Search Market Share as of April 2011

  1. Google (65%)
  2. Bing (17%)
  3. Yahoo! (13.80%)
  4. Other (4.20%)

Before I can start teaching you about optimizing a web site you need to understand how search engines work. A search engine is an online portal that indexes and ranks web sites. Users will access the search engine portal to try to find the correct answers to their problems. Answers are created instantly by using a the engine???s search algorithm. This algorithm will take the the user???s query and compare it with the pages that are on it???s index. It will then create a list of web pages that will try to answer what the user was asking for.

So how does a search engine finds out about my web site? Search engines have an online application built in them known as a Web Crawler or Spider. The sole role of this application is to find and check for updates on web pages in the world wide web. Once a spider finds a web page it will check in the main engine directory to see if the page has been indexed before. If the given web page has not been indexed or if it was updated since the last time the spider visited the page, it will insert it into a separate queue. Another application/bot will access the page to cache the information and the code in it. If the page has not been updated since the last time the bot visited, it will leave it alone and move on to the next one.

I will be referring to Google’s algorithm when referring to a search engine algorithm as this is the one with the biggest search engine market piece. Be aware that search algorithms are constantly changing, so what I write today might change tomorrow.

Here are the major factors that are taken into consideration by the search algorithm to produce the results. Information gathered from SEOMoz

  • 24% Trust/Authority of the Host Domain
  • 22% Link Popularity of the Specific Page
  • 20% Anchor Text of External Links
  • 15% On-Page Keyword Usage
  • 7% Traffic and Click-Through Data
  • 6% Social Graph Metrics
  • 5% Registration and Hosting Data

To rank for a certain keyword you need to succeed in all of the algorithm ranking factors. The web site that has the best factors to it is the one that will rank best, or show up higher in the rankings. I will be teaching you how to optimize your web site to achieve the best results possible in all of the ranking factors. You need to have paciense and know than to rank for a term it takes time. You first need to get the page indexed, then get your content cached and then start building your authority. Once you get all of your this together you will begin seeing the results.

On my next lesson I will begin to explain the process of optimizing a web site, which is analyzing the market that you want to rank for and doing a proper keyword analysis. This is a very important step on your campaign as it will dictate how your whole pre-launch campaign will be based on. This is will get you categorized in the search engine eys for certain terms, the most accurate you get categorized the first time, the easier it will be to adjust and earn a higher authority.

Please feel free to leave any comments or questions below.

Creating Google Calendar Events with PHP

Many small businesses are now using the extensive Google Apps for Business framework to manage many of their daily activities. However due to the increase of Cloud Applications being programmed as well to assist this businesses, sometimes they have to be importing their online application information into their Google Apps. With the available API’s however this has not to be necessarily the case.

Using the new Google Calendar API and the following PHP code you can easily create events dynamically when they are generated in your cloud business application. Please be aware than in order to connect through their API you will need to have Zend installed on your server.

// Load required libraries
$path = 'Zend/Gdata';
$oldPath = set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once 'Zend/Loader.php';

class google {
	public $client;
	public $service;

	function createCalendarEvent( ) {
		// Authentication with Google
		$user = '';
		$pass = 'userPass';
        // Load required libraries
		 // predefined service name for calendar
		$serviceName = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
		$this->client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $serviceName);
		$this->service = new Zend_Gdata_Calendar( $this->client );
		// get time
        $this->eventStart = "07:00:00";
        $this->eventEnd = "08:30:00";
		// Create a new event to add required parameters
		$event = $this->service->newEventEntry();
		// Create a new title for your calendar event
		$event->title = $this->service->newTitle( 'My First Google API Interaction' );
		// Set a location for your event
		$eventAddress = '123 Test St, Chula Vista';
		$event->where = array( $this->service->newWhere( $eventAddress  ) );
		// You can also add aditional information to your appoitnment
		$event->content = $this->service->newContent( 'Extra event information');
		$when = $this->service->newWhen();
		// Set start and end times
		$eventInfo = '2008-09-08';
		// 2008-09-08T22:47:31-07:00 (For Pacific Times)
		$when->startTime = $eventInfo . "T" . $this->eventStart . "-07:00";
		$when->endTime = $eventInfo . "T" . $this->eventEnd . "-07:00";
		// Set the when attribute for the event
		$event->when = array($when);
		// Create the event on google server
		$newEvent = $this->service->insertEvent($event);
		// URI of the new event which can be saved locally for later use
		$eventUri = $newEvent->id->text;


How much is Search Engine Optimization worth?

Many times clients are not aware of the actual worth of Search Engine Optimization (SEO) in their company’s website and they utilize other methods of internet marketing.  What they are not aware of is that if they were to use SEO they can save up to 80% of their budget and maximize their Return on their Investment (ROI). For example for a pest control company in San Diego going for the keyword “San Diego Pest Control” they could save an average of over $11,000 if they were to be on the number one spot of the organic results versus if they were using a pay per click (PPC) method.

We can calculate the worth of organic keywords by using a variety of methods. My prefer way is to use the Google Keyword Tool to calculate their value. On this tool Google gives us important information like how many times a keyword is searched and what is the approximate cost per click (CPC). This information combined with the know click-trough rate information on organic results will provide you the worth of any given keyword.


First here are some click-trough rate statistics

Rank 1 18%
Rank 2 10%
Rank in top 10 52%
Below the fold 4%


Now we will retrieve the desired keyword information using Google’s Keyword Tool

Keyword San Diego Pest Control
Global Monthly Searches 4,400
Approximate CPC $14.13


Using this information we can calculate the worth of the keyword using the following formula:

{Global Monthly Searches} X {Approximate CPC} X {Click Trough Rate}


Rank 1 4,400 X 14.13 X .18 $11,190.96
Rank 2 4,400 X 14.13 X .10 $6,217.20
Rank in top 10 4,400 X 14.13 X .52 $32,329.44
Below the fold 4,400 X 14.13 X .04 $2,486.88


As you can see the worth of a keyword in the organic search results is bigger that what the average person believes. Please note that this is only the worth of a single keyword, many search engine optimization campaigns when done properly can achieve infinity of number 1 ranks in searches with related keywords. There are many businesses that spend a large part of their budget in campaigns that will not maximize their ROI. Search Engine Optimization is not only more affordable that inbound marketing efforts but it will also create a better online reputation for your business.

Please leave any comments or questions in the form below

New Web Sites Do Not Validate

HTML and CSS Validation is a tool that was created in the beginning of the World Wide Web to make sure that web sites were constructed correctly. Many times when creating projects using new technologies, for multiple devices or that use third party applications we come to the problem that it does not validate according to the W3C standard. There are many developers and clients that react in a bad way when they see errors when validating and believe that the application still has bugs in it. Many time developers have to go back and change features just to make the site get a perfect score. Many times this makes the development time longer and the project more expensive. Developers and clients have to remember that validation is only a tool and nothing more than that, and while we do need to follow the standards set by the W3C we also have to make sure that usability and functionality are our top priority.

Usability over Technicalities

We always have to keep in mind that everything that we develop is intended for a person and not for a machine. Usability and Functionality for the target user of the application is the goal that we always try to achieve. While robots from search engines might crawl the application, we have to remember they are not our main audience. We also have to keep in mind that Google does not take validation as a ranking factor. You can see more about Google’s stand on this matter in the following video made by Matt Cuts for the Google Webmaster Forum:

[Video Removed]

When using many of the newer CSS3 techniques there will be an error created in the validation tool. For example when using border-radius that help us give rounded corners to our backgrounds. To go around this the designer has to design the curves and the developer implements them, which will take longer that using CSS3. We have to keep in mind that cases like this we have to always put user usability over irrelevant technicalities.

Validation is Irrelevant yet Important

While your validation score does not affect how search engine see you, it might still give you an extra boost in search engine optimization or SEO when the algorithm is looking at the web page overall usability. Validation as well still an important tool to review when working on a project. This tool will help you find unclosed tags and improperly nested div’s, extra semicolons, among other things. There will always be the error from Google’s Analytics or from that jQuery slider but as long as the integrity of the structure is impeccable you do not have to worry about the validation score from the W3C Tool. Remember that the score is only there to help you build a useable application; there is no target score you want to achieve just as long as you get 100% in usability with your target audience.

Please feel free to leave any questions or comments below.

Are your Internet Marketing Keywords targeted properly?

The most important step when starting an Internet Marketing Campaign is by far keyword research. There are many ways that this can be done depending on the goals that your business is trying to achieve. As an example, when your company is trying to achieve brand awareness your keywords will be more broadly worded. In the other hand, if your company is looking to make sales the keywords will be more specific to your target audience. The direction of your Internet Marketing Campaign needs to be fully established before any work can be even started, if not you will only be using assets or time that can be important later on.

Communication is very important to have with your Internet Marketing Agency. By this you will be making sure that the process flows with no inconveniences. While your keyword research is being complete be sure to give your feedback to your SEO Consultant, this is because there are many terms that are industry specific and by him knowing them it will make your campaign more successful.

There are many factors that will make your campaign successful but why is keyword research the most important of all? It is the most important Internet Marketing Campaign factor because all of your actions will be derived from this important document. You will decide what SEO Content to write using this list as well as how to structure your web site along other things. Be aware that if your keyword research is improper or not completed to suit your business needs the return on your investment will not be as high. Imagine a termite control business trying to generate sales leads in San Diego, ranking for “Termite Control” is great and is potentially bringing him a large amount of visitors. However, because the term is so broad it will not convert. But if the same company ranks for “San Diego Termite Control” then the number of visitors that is in their target audience is greater which will then turn into more conversions.

Take a look at your Internet Marketing Campaign Keyword Research and analyse your terms to see if they are the most appropriate one for your business goals. Please feel free to give us a call or send us a message with any questions, we will be happy to review your keyword analysis at no cost to you so that you have the tranquility that your business is in the right track.


Enjoy this blog? Please spread the word :)