Sugar Developers now have a new tool for building upgrade safe mobile customizations that address most branding, theming, and mobile security requirements.

Introducing Sugar MACS

Introducing the Sugar Mobile Application Configurator Service (Sugar MACS)! This tool allows Sugar Developers building solutions for Sugar Enterprise customers to create and distribute custom-branded versions of the SugarCRM Mobile app.

Many of you have seen earlier previews of Sugar MACS at SugarCon and UnCon.

Continue Reading…

Sugar Performance Engineer Vadzim Ramanenka shares some tips for profiling Sugar code using our newly launched SugarCRM XHProf Viewer open source project.

Profiling Sugar softly

Whenever you encounter that something is not working as fast as you would like, you need a way to look “under the hood” and understand what exactly is slowing things down. Sugar 7.7.0 added a built-in capability to collect detailed performance profiling data and store it in files. Recently, we released an open source SugarCRM XHProf Viewer project which can be used to visualize performance bottlenecks.

XhprofCallGraph.png

Example of a XHProf call graph diagram

Read on to learn how to configure both Sugar and the Viewer in a few simple steps.

Continue Reading…

You may have heard that SugarCRM will be presenting a series of webinars on solution architecture for the Sugar platform, throughout this September and October.

Beginning on September 6th, Sugar University’s Solution Architect Webinar Series will present the following topics:

  • Introduction to Solution Architecture for Sugar
  • CRM Project Fundamentals
  • The Sugar Platform
  • Design
  • Integration
  • Sugar Implementation
  • Performance and Quality Assurance
  • Deployment
  • Security

Each webinar will be guided by a panel of experts from across SugarCRM, including some familiar faces from the Architecting Successful Projects panel at this year’s UnCon

Continue Reading…

Here is a guest post from Ivica Nedeljkovic from Intelestream which is one of our new SugarCRM Partners. In this post, Ivica explains how you can use Intelestream created Docker containers hosted on DockerHub to easily deploy Sugar.

If I was asked to list the top five technologies in the last 5 years, Docker would certainly be on the list.The real advantage that Docker containers have over other server virtualization software is that Docker uses shared operating systems instead of trying to virtualize hardware. This takes less resources, is easier to boot, and faster to spin up instances.

docker_28container_engine29_logo

Docker 1.12

Some performance issues were experienced with Docker containers on OS X and Windows and some security issues were also experienced because up until Docker version 1.12. Until Docker 1.12, the native OS X/Windows virtualization options were not used and 3rd party Linux virtual machines such as VirtualBox were used instead. For virtualization, Docker 1.12 for Windows uses Alpine Linux on top of a Hyper-V VM and Docker 1.12 for Mac OSX uses Alpine Linux on top of a xhyve Virtual Machine.

Docker 1.12  was released in July 2016. In addition to boosting performance it also simplifies the whole process of creating new containers, as you no longer need to use a docker-machine anymore to create virtual machines.

DockerHub

For this project, we store Docker container images on DockerHub. DockerHub allows developers to use pre-built images that are stored in the web repository. Additionally, every time a developer makes a change to a Docker config file, these changes can be pushed back to DockerHub to generate new automated builds. This simplifies the process if you want to deploy your container image on a number of servers. For example, you can set triggers and hooks. DockerHub allows you to have a number of public repositories and one private repository for free. If further private repositories are required then additional packages can be purchased.

We are using docker-compose to create different containers for web app (php 5.5, Apache), db server (Mysql 5.6), Elastic Search (required for the professional version). As a bonus we added a container with phpmyadmin that you might need to manage a mysql databases.

Launching Sugar using DockerHub Containers

Follow along to start using Sugar via DockerHub containers.

Step 1: Install Docker 1.12 or later

This is a recommendation and not a requirement. An older version of Docker or Docker Tools can be used, but in such a case you must use a docker-machine command to create a virtual machine for Docker to run inside and set environment variables. Should you choose to run one of these options instead of Docker 1.12 you will notice that the remaining steps are similar to those listed below.

Step 2: Clone intelestream/sugarcrm-docker.git repository

git clone git@github.com:intelestream/sugarcrm-docker.git

In case you already have some service listening on ports 80 (Apache), 3307 (MySql – custom port), 9200, 9300 (Elasticsearch) or 8181 (PhpMyAdmin) please disable them. Alternatively, you can also modify these ports in the docker-compose.yml file for all of these services, with the exception of the web server port. Sugar uses the file_get_contents command which does not work with ports (just for checking installation requirements).

Step 3: Run docker-compose to start images

Using the console, navigate to the folder that has been created and type:

docker-compose up

This command will download all images from the DockerHub and start building containers. Spinning up containers for the first time will be fairly slow but as soon as all images are downloaded then the process will speed up considerably.

Once everything is completed, you should have containers with Apache, MySql, and Elasticsearch running. To stop/pause them, use “CTRL+C”

At this point all services should be running. Our public web folder is www. To check if everything is running as expected you can test by creating a test.php file under there and accessing it within your browser:

http://localhost/test.php

Step 4: Place Sugar code and run Sugar installer

Copy Sugar application code to the www directory and place it in a directory named sugarcrm. The system is designed for developers to be able to have more than one instance of Sugar. All you need is multiple individual databases.

Open http://localhost/sugarcrm (or whatever name you decided to assign to the above folder) and enter the following in the Sugar installation wizard:

Host: mysql_crm

(The host needs to be mysql_crm, it will be resolved by docker.  See docker-compose.yml)

DB Name: sugarcrm

DB User: sugarcrm

DB Password: sugarcrm

root user: root

root password: sugarcrm

Elasticsearch Host: elasticsearch_crm

(See host again in docker-compose.yml)

Elasticsearch Port: 9200

Finished!

Sugar is now up and running! Happy coding!

Below are some tips for working with this server set-up.

Accessing the MySQL database

phpMyAdmin is installed if you need to administer your MySQL database. You can access phpMyAdmin by opening the following url:

http://localhost:8181

Accessing a command line for a container

In case you need to access any containers:

docker ps 

This lists all of the containers and their IDs.

In the command below replace container_id with the container id you want to connect to based on the results of the previous step:

docker exec -i -t container_id /bin/bash

Setting up Cron from command line

First, retrieve a command line for your Apache server instance using the previous steps. Then to set up a cronjob, run the following line:

cd /app/www/crm; /usr/local/bin/php -f cron.php > /dev/null 2>&1

And start Cron service:

service cron start

If you shutdown and remove container, you will need to set up the cronjob again for new instances.

Additional Considerations

  • When you repair and rebuild your caches, you will notice a decrease of around 40-50% in terms of speed in comparison with an instance of Sugar running directly on the host, because many files need to be written and synced between systems. If you do not do this action too often you will not notice a big difference between performance
  • If you do not need all containers, you can comment those you do not need in the docker-compose.yml file. For example, if you do not want to use both the web server and MySQL server because you can use them from your local host, then you can simply have only Elasticsearch running in a container so you do not need to install it. Even simpler, you could just download the Elasticsearch image from the official repository on DockerHub and start it!

At SugarCRM, we have been accelerating the rate at which we share technology with the Sugar Developer community. Back in June at UnCon, we shared more open source code examples and tools than ever before. In April, we announced Sucrose Charts and the Sugar REST Harness. I am pleased to announce that we have open sourced three more projects under the Apache-2 license!

Continue Reading…

Here is a guest post from Sugar Developer Francesca Shiekh who works for our customer Wolfram Research. She also happens to be one of the most active developers in the Sugar Developer Community! In this post, Francesca and Wolfram Research Systems Administrator Trey Mitchell share how you can customize Sugar to use an alternative PDF generator for the creation of PDF documents in Sugar.

Creating better PDFs with CSS

Screen Shot 2016-08-05 at 2.41.58 PM

We wanted a custom Contracts module that allowed specific styling to be applied to all Contract PDFs.  We determined that we could use CSS to apply a consistent style to any and all PDF documents associated with this new custom Contracts module. But we could not achieve this with SugarPDF due to the complexity of our CSS. Also overriding sugarpdf.pfdmanager.php was not an option as it is an extension of TCPDF and TCPDF has limited CSS support.

It was therefore necessary for use to look at alternatives that could better handle CSS.  We found a promising open source tool called wkhtmltopdf that uses WebKit.  WebKit should be familiar because it is the same layout engine used in Safari and Google Chrome, and is therefore very accurate in rendering CSS.

We still wanted to leverage the PDF Manager module to create and maintain our PDFs. We planned to develop our Contract templates in HTML with our own custom CSS and then copy them into the HTML editor that was already available in PDF Manager.

Read more below to find out how we made it work.

Continue Reading…

Alex Vlasov is an experienced Sugar Developer and contractor that works on the SugarCRM Engineering platform team. In this post, Alex shares advice to Sugar Developers for preparing their Sugar customizations for PHP 5.6 and PHP 7.

The Sugar team has been preparing core Sugar code for PHP 5.6 and PHP 7 support with an eye on deprecating support for older PHP versions. This means there are some actions that the Sugar Developer community needs to take in order to prepare their code for latest versions of PHP.

Summary of core Sugar app changes

In order to support newer versions of PHP, we made some changes to internal core classes that Sugar Developers need to know about. Many of these changes were made in Sugar 7.7.1 when we added PHP 5.6 support. Other changes outlined below are in upcoming Sugar releases.

PHP 7 deprecated features removed from core Sugar code

  1. Removed static calls to non-static methods
  2. Removed PHP4-style constructors

Read the full list of features deprecated in PHP7.

Additional changes to address core Sugar code hygiene and to adopt new PHP 7 features

  1. Fixed incompatible child class methods signatures
  2. Updated 3rd party libraries to support latest versions of PHP
  3. Changes to support PHP 7.0 new uniform variable syntax
  4. Adopted PHP 7’s CSPRNG API but added random_compat library to support older PHP versions

Actions for Sugar Developers

In order to properly upgrade custom code, two main tasks need to be performed:

Make your code compatible with PHP 5.6 and PHP 7.0

To make your code compatible with PHP 5.6 and 7.0, use the following checklist.

  1. Remove static calls to non-static methods within your PHP code
  2. Remove any use of PHP4-style constructors within your PHP code
  3. Remove other deprecated PHP functionality in your PHP code (PHP 5.6 deprecated features, PHP 7 deprecated features)

For example,

class Foo {

	public function __construct() { // Yes.
		// ...
	}

	public function Foo() { // No.
		// ...
	}

    public static function aStaticMethod() {
        // ...
    }

    public function aNormalMethod() {
    	// ...
    }
}

Foo::aStaticMethod(); // Yes.
Foo::aNormalMethod(); // No.

For additional detail, refer to PHP migration guides for PHP 5.6 and PHP 7.0.

Make your code compatible with changes to Sugar PHP APIs

To make custom code compatible with updated Sugar PHP APIs, use the following checklist.

  1. (7.7.1) Do not use old PHP4 constructors in Sugar PHP classes, they are removed as part of PHP 7.0 support.
  2. (7.7.1) If there is code that extends Sugar PHP classes, make sure child methods signatures are correct
  3. (7.7.1) 3rd party libraries were moved:
    1. parsecsv library was moved to the vendor directory
  4. (future) 3rd party libraries updates:
    1. Elastica library will be upgraded, so make sure you do not use deprecated Elastica APIs.
    2. Removal of mcrypt support and Crypt_Blowfish library, so make sure you are not calling these libraries directly.
  5. (future) Significant changes to be made to the following Sugar PHP APIs:
    1. ActivitiesApi::getQueryObject() will become protected and function arguments are changed
    2. RelationshipHandler class will stop extending Relationship class
    3. SearchForm class will not extend EditView class anymore
    4. Quarter*TimePeriod::buildLeaves() methods will have function arguments changed
    5. PMSEEngineFilterApi::addFieldFilter() method will be renamed