Composer in PHP: Installing on Ubuntu & Use case

Composer is an application package management tool which is used only for PHP language. It provides standard format of library structure with dependencies of PHP version. We can also called it library provider. It’s also used for dependencies manager for PHP.

Installation Steps:

First check composer is already installed on the system or not,

Steps to check:-

-> Go to command prompt

Type command “composer

=> You can find output like below. If you get the result like below it means composer is already installed in your system.

Composer is Not Installed:-

=> If your system has not installed composer, then output will be like below.

If the system doesn’t have Composer, then first install composer

Steps to install Composer:-

1) Update your system first, to update your system use below commands in terminal.

=> sudo apt-get update
=> sudo apt-get upgrade

2) Install composer using below command and check composer installed or not …

=> curl -sS | sudo php — –install-dir=/usr/local/bin –filename=composer

Once the command runs successfully, the composer is installed on the system.

3) Now, check again composer installed or not, using command => “composer”

Composer installation is done now. Now you can use composer for installation of your modules.

What is the Use of Composer?


What is the use of composer in any project?

-> Composer manage dependencies of PHP on it’s own, so the developer doesn’t have to worry about different version dependencies. This composer concept is not new, in fact it is inspired by NPM NodeJS. Composer is good for code reusability. Maintain dependencies of whole project.

How to use Composer in your project?

-> For composer use in your project. There are 2 main requirements

1) Composer should be installed on the system
2) In the project folder composer.json file must be available.

-> In the project folder in command prompt and run command “composer install”.

If composer.json file is not there, then you can directly install your library using command “composer require “{Package Name}”” Package name Like :” paypal/rest-api-sdk-php:*””. It will auto generate composer.json file in the system.

After installing the packages, check the project folder. It should have created one new folder, named with “vendor”. Folder name is permanent, and it will move all packages which were installed in the project to vendor folder. Inside the vendor folder you can see “autoload.php” file.

Autoload file will be helpful in the projects. You can include autoload.php file in your code file and get access to any package by class name to get it work.

In your project using below steps:

-> mkdir “Project name”
-> cd Project name
-> Run composer command “composer require “paypal/rest-api-sdk-php:*””

Note: This command will create new composer.json and composer.lock file and vendor folder that includes all the dependency and library files of the installed packages.

-> Autoload.php file is in vendor folder. Use the file name (autoload.php) in your regular file and get access with class name of the packages.

Please share your thoughts, questions on this article. If you need further assistance, in installing composer on Ubuntu, please don’t hesitate to contact us.

cmsMinds is a web development agency based in Raleigh, NC. Apart from helping on cms projects, we have expertise on custom web development using PHP. If you need help with one of your existing projects or architecting a new application one of our team members can definitely help you with the road map.

Entity Reference & Entity Reference View in Drupal 8

What is Entity Reference?

The term “Entity Reference” literally means reference to the entity. Entities are used to store data, which could be a node, a user, a taxonomy term, or a custom drupal development.

Entity Reference is an important module to build relationships between entities in Drupal. Below are some of the examples of relationship:

1) A taxonomy term associated with a user account.
2) A parent content that references a child content element.

How to use Entity Reference?

Below are the steps to use entity reference in Drupal 8.

Step1: Create settings related to Entity Reference module from backend.
Step2: Create Content type.
Step3: Add/Edit fields of content type through Home -> Administration -> Structure -> Content Types -> Content type (ie:user) -> Manage fields, Add a new Entity Reference field.
Step4: Choose the number of values.
Step5: Set Entity Reference type.
Step6: Select Entity Reference method.
Step7: Set the target bundles.
Step8: For Views: Filter by an entity reference view and follow screen-shots, below.

As we complete above steps – you can view changes in front as well.

What is Entity Reference View?

For Drupal content creators, Entity Reference Views is a great way to make content management easier.
Normally, when users create content on the site, each field is very plain. However, Entity Reference Views allows you to provide for more information. For example, instead of just showing a list of users, your content creators can browse through a list of names, photos and personal details.

How to use Entity Reference View?

Steps to use Entity Reference View in Drupal 8.
1) Create a content View.
2) Add a field with the Entity Reference View.

Below are the steps that combine steps of Entity Reference and Entity Reference View explained with screenshots.

1) Create Content Type:

2) Add Entity Reference field:

3) Create Entity Reference View to use it as Entity Reference and set it as Entity Reference in Reference method:

4) Create another Entity Reference View:

5) Add Entity Reference while creating Entity Reference View:

6) Change Reference Type from default to views: Set entity reference view (created in step4) in Reference method while setting reference type.

Hope the article helps you how to use Entity reference module in your project. If you need help or have any follow up questions, please don’t hesitate to contact us @ cmsMinds is a drupal web development company in Raleigh,NC, based in Raleigh with expertise in open source CMS (WordPress, Drupal) and PHP.

Paragraph Module in Drupal 8

To make your content more appropriate and easy we have come up with a new module that will help you to segregate the content into paragraph.Paragraph module: It provides more editing power to end users. It allows option to add content based on the Paragraph type instead of inserting whole content section in WYSIWYG body. Install module for configuring this option in Drupal 8 website.

For this tutorial, we will create a basic Content paragraph type which will have two fields: Left Image and Description.

Steps for adding these fields in paragraphs type.

1. Go to the navigation bar click on Structure and “Paragraphs types”.

2. On this link “Add a Paragraphs type” button will be available for adding paragraphs type in site. Click on “Add a Paragraphs type” button.

3. You just need to add paragraphs type name (Demo) and click on save button for adding Paragraph type.

4. Now, add fields in this paragraphs type.

5. Add two fields (image and text) in this paragraphs type.

For using this paragraphs type in website, add this paragraph field to content type ‘Article’ as field. Check below image for adding field as Paragraph type.

Create Article with Paragraph fields.

1. Go to Content, “Add content” and click on Article.

2. Enter “Test article” in the Title and scroll down to the Paragraphs Demo field.

3. Click on the Add Demo for adding left image and Desc paragraph content with respect to Article. After adding it, you should be able to see the content of this Paragraph.

To reciprocate, we can manage the content of the website by dividing whole page section into different paragraph type.

As a Drupal development agency in Raleigh USA, we have a team of experts who specializes in different aspect of Drupal development. We have team members whose focus is to have a clean design and renders well across all browsers and devices. The Drupal backend developers’ focus is to build custom Drupal modules and integrate with different applications.

For more assistance you can contact us on or fill out the Contact us form.


How to setup Multi-site in Drupal 8

Drupal 8 provides multi-site feature to use same code for different sites. You can manage multiple websites easily using the multi-site feature of Drupal 8. Multi-site allows you to use a single Drupal installation for several sites with core code, contributed modules and themes. You can also manage configuration settings and database separately for each site so it will have its own content, settings, enabled modules and enabled theme. We have shared two flow for managing multi-site feature.

How to setup multisite in Drupal 8 with different database?

Step 1: Download latest Drupal 8 and extract code in your project directory with respect to your environment like WAMP, MAMP, LAMP, XAMPP, etc.

Step 2: Go to “sites” folder and create the following folders , as per the below Structure image.

Note: Please create virtual hosts ( and in your localhost environment.

Step 3: In “sites” folder copy “example.sites.php” and rename file to “sites.php” and add the following lines to configure the above sites in your Drupal 8 website.

$sites[‘’] = ‘’;
$sites[‘’] = ‘’;

Step 4: We need two databases for both websites so create domain1_db and domain2_db database respectively for and sites.

Step 5: After above configurations, install both the site using below URL and after installation, access multi-site feature.

How to setup multisite in drupal 8 within a single database?

We need to follow the same Step1, Step2 and Step3 as above.

Step 6: Create one database domain_db for managing multi-site through single database.

Step 7: After above configurations, install both the site using below URL. After installation access your multi-site feature. During the installation, use different table name prefix for each sites configuration. Please do check table prefix configuration image.

After adding different prefix to each site, it will have it’s table in single database. Please do check the attached Database Table image. We have added test1 prefix for

Hope, the article helps you get an overview of how to setup multi-site with same code. As a leading Drupal development company in Raleigh, NC, we have qualified team of nerdy Drupal developers. If you working on a project and need some help, please contact one of our team members and see how we can help you.

How to use GITHUB to contribute to Drupal core or module?

Git is a leading version control system for software projects and uses Github for version control with it’s developers and Drupal community to build it’s core and contrib module. In this blog, I will share my experience on how to use Github to contribute code to

Drupal follows git’s branches and tags for managing code. Steps and naming conventions.


1. A branch manages the commit code, and it moves forward automatically.

For Drupal to release naming conventions for branch first time use below naming conventions.

7.x-1.x (For Stable and dev)

8.x-1.x (For Stable and dev)


Below are not valid naming conventions:

7.x-1.1 (For Stable and dev)

8.x-1.1 (For Stable and dev)


2. Tags are used for creating releases of the project.

Below are valid naming conventions.


7.x-1.0-dev1 (For dev)

8.x-1.0-dev1 (For dev)

7.x-1.0-alpha1 (For alpha)

8.x-1.0-alpha1 (For alpha)

7.x-1.0-rc1 (For dev)

8.x-1.0-rc1 (For dev)

7.x-1.1 (For Stable)

8.x-1.1 (For Stable)


Below are not valid naming conventions.

7.x-1.0-release1 (wrong word)

7.x-1.0-rc (doesn’t end in a digit)

7.x-1.0-UNSTABLE1 (uppercase)


List of command to use git for Drupal code contribution.

  1. Install GIT on the system
  2. Configure GIT using below command
    1. git config “”
  1. After the configuration, you can clone the project using GIT command. Example below:
    1. git clone –branch 8.4.x
  1. Go into the project directory by below command
  2. cd drupal
  3. Now check git status (Show the working tree status and check the repository status.)
  4. To check branch under this project. We have to use command git branch (Show the branch and tracking info.)
  5. To get list of tags use git tag -l (Get list all Git tags)
  6. For adding a new branch use below command
  7. git checkout -b 8.x-1.x (First create the new branch and check it out)
  8. git push origin 8.x-1.x (Once the branch is created locally, it can be pushed up to the remote repository)
  9. git checkout 8.x-1.x         (To work with this branch)
  10. For adding, a new tag use below command
  11. git tag 8.x-1.0         (First create the new tag)
  12. git push origin tag 8.x-1.0 (Once the branch is created locally, it can be pushed up to the remote repository)
  13. If you want to switch to a different branch, use below commands.
  14. git branch -a
  15. git checkout [branchname]
  16. Committing all changes locally using below commands.
  17. git add -A
  18. git commit -m “Issue #[issue number] by [comma-separated usernames]: [Short summary of the change].”
  19. Pushing the code back to the repository on
  20. git push -u origin [branchname]


If you haven’t cloned the repository, follow the directions above for setting up this repository in the local environment. Be sure you are on the branch you wish to patch, then ensure it is up-to-date with the following command:

git pull origin [branchname]


Creating a patch

For improvements, use the following command after making changes:

git diff > [description]-[issue-number]-[comment-number].patch

For more complex improvements see the Advanced patch workflow.

Applying a patch

Download the patch to the working directory. Apply the patch with the following command:

git apply -v [patchname.patch]

To avoid accidentally including the patch file in future commits, remove it after applying patch to the directory.

rm [patchname.patch]

When you’re done: Reverting uncommitted changes

Revert changes to a specific file:

git checkout [filename]

Revert changes to the whole working tree: git reset –hard

 I hope the article give you the basic information on how to use GITHUB and contribute to the community. cmsMinds actively participates in Drupal community and has contrib modules it maintains. Please share your feedback and let us know if we can help you as custom Drupal development company in NC, USA.

Quick Inquiry