Add a Cron Job and Command

There is no config to register a cron job in OroPlatform. There are 2 steps to add a cron job:

  1. add a command class in the bundle
  2. run a CLI to add the job in table oro_cron_schedule

The added class can be run as a command in CLI when it is defined as a Service.

Add a Command Class

src\Stars\Bundle\LoggerEventBundle\Command\InsertActionDataCommand.php

<?php

namespace Stars\Bundle\LoggerEventBundle\Command;

use Oro\Bundle\CronBundle\Command\CronCommandInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\...

Service

What is a Service?

A service is a discrete unit of functionality:

  1. It logically represents a business activity with a specified outcome.
  2. It is self-contained.
  3. It is a black box for its consumers.
  4. It may consist of other underlying services.

Put simply, a service is any PHP object that performs some sort of global task.

You don't have to do anything special to make a service: simply write a PHP class with some code that accomplishes a specific task.

In Symfony...

Create a Doctrine DBAL Connection for Another Database

There are 3 ways to create a DBAL connection to access another database:

\Doctrine\Bundle\DoctrineBundle\ConnectionFactory

/** @var \Doctrine\Bundle\DoctrineBundle\ConnectionFactory $connectionFactory */
$connectionFactory = $this->getContainer()->get('doctrine.dbal.connection_factory');
$connection = $connectionFactory->createConnection([
	'pdo' => new \PDO(
		"mysql:host=$hostname;dbname=$dbname", 
		$username, 
		$password)
]);

$connection->executeQuery('SELECT * FROM your_table');

\Doctrine\DBAL\DriverManager

/**
...

Override an Override Service with Compiler Pass

I wanted to increase the length of name for MySQL table from 30 to 64 as I encountered this error:

[kiat@reporting misoro]$ sudo -u nginx php bin/console oro:migration:load --force
Process migrations...
Oro\Bundle\EntityExtendBundle\Migration\LoadEntityConfigStateMigration
Stars\Bundle\LoggerEventBundle\Migraions\Schema\v1_0\StarsLoggerEventBundle
    ERROR: Max table name length is 30. Please correct "sc_stars_logger_event_action_data" table 
in "Stars\Bundle\LoggerEventBundle\Migraions\Schema\v1_0\StarsLoggerEventBundle" migration
`...

Add a Basic Controller in Oro Platform Application

After we have our bundle, we can add a controller with just 2 files.

Add a Controller Class

Add file src\DbugBundle\Controller\DbugController.php

<?php
namespace DbugBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Response;


/**
 * @Route("/dbug")
 */
class DbugController
{
    /**
     * @Route("/phpinfo", name="dbug_phpinfo")
     */
    public function phpinfoAction(): Response
    {
        ob_start();
        phpinfo();
        $html = ob_get...

Install Oro Platform 3.1.3 on Centos 7.4.1708 - Nginx 1.12 - PHP 7.1

Reference the official install guide.

We are using Symfony Framework v. 3.4 LTS in Oro Applications v.3.x.

Errors I Encountered and How I Fixed Them

Apache is Active

Check Port 80

[kiat@reporting /]$ sudo netstat -tulpn | grep :80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      55851/httpd

Port 80 is used by Apache (as user httpd).

Disable Apache

[kiat@reporting /]$ sudo...

OroPlatform API - Deleting Entity - API Testing - WSSE Authentication

In the Creating a Simple CRUD cookbook, it uses REST API to delete entities. However, the description isn't enough to properly implement the delete operation.

However, there are examples on how to do it in the \vendor\oro\platform codebase. Reference vendor\oro\platform\src\Oro\Bundle\OrganizationBundle\ on coding for REST API. The files of inter...

Create A Bundle

Prerequisites

Official OroPlatform guide on installation and setup.

What is a Bundle?

All OroPlatform-based applications have unique features that facilitate smooth development routine, like autoregistration of bundles and configuration files, for example.

However, these features assume that all application code is organized in bundles. For this reason, you have to create your own bundle for your custom code in order to perform...