---
title: Code validations using static-review library in Magento
description: Magento2 comes up with some advance tools and plugins, which are rarely useful for developers to track some common errors during development; we are going to introduce a small tutorial, which helps developers to validate PHP scripts before committing code to Git branch.
image: https://blog.e-zest.com/hubfs/code-validations-using-static-review-library-in-magento.png
---

[![e-Zest logo\_An accion lab company\_Colour](https://blog.e-zest.com/hubfs/images/Logos%20with%20Tagline/Corporate/SVG/e-Zest%20logo_An%20accion%20lab%20company_Colour.svg "e-Zest logo_An accion lab company_Colour")](https://www.e-zest.com/)

- [WORK](https://www.e-zest.com/our-work)
- [SERVICES](https://www.e-zest.com/our-services) 
    - [Product Engineering](https://www.e-zest.com/digital-product-engineering-services)
    - [Enterprise Data Services](https://www.e-zest.com/enterprise-data-services)
    - [Digital Commerce](https://www.e-zest.com/digital-commerce-services)
    - [Digital Operations](https://www.e-zest.com/digital-operations)
    - [Digital Consulting](https://www.e-zest.com/digital-transformation-consulting-services)
    - [Digital Experience Design](https://www.e-zest.com/digital-experience-design)
- [INSIGHTS](https://blog.e-zest.com/)
- [CAREERS](https://www.e-zest.com/careers)
- [ENTERPRISE DATA SERVICES](https://www.e-zest.com/enterprise-data-services)
- [GENERATIVE AI](https://www.e-zest.com/generative-ai)
- [Healthcare](https://healthcare.e-zest.com)
- [Contact Us](https://www.e-zest.com/contact-us)

- ![Elevating Product Engineering with AI and ML](https://blog.e-zest.com/hubfs/Elevating%20Product%20Engineering%20with%20AI%20and%20ML.jpg)

  [BLOGS](https://blog.e-zest.com)
  
  #### Elevating Product Engineering with AI and ML

  As technology evolves and customer choices broaden, there is an increasing ...

  [Read more](https://blog.e-zest.com/elevating-product-engineering-with-ai-and-ml)
- ![e-Zest – An Accion Labs Company gets Recognition as a Contender in the ISG Provider Lens™ Study on Digital Engineering Services 2024](https://blog.e-zest.com/hubfs/e-Zest%20%E2%80%93%20An%20Accion%20Labs%20Company%20-%20Gets%20Recognition%20as%20a%20Contender%20in%20the%20ISG%20Provider%20LensTM%20Study%20on%20Digital%20Engineering%20Services%202024.jpg)

  [NEWS](https://blog.e-zest.com/news)
  
  #### e-Zest – An Accion Labs Company gets Recognition as a Contender in the ISG Provider Lens™ Study on Digital Engineering Services 2024

  We are delighted to announce that e-Zest – An Accion Labs Company has been ...

  [Read more](https://blog.e-zest.com/news/e-zest-an-accion-labs-company-gets-recognition-as-a-contender-in-the-isg-provider-lens-study-on-digital-engineering-services-2024)
- ![e-Zest Solutions supports Digital Pune Mission](https://blog.e-zest.com/hubfs/blog-files/Digital%20Literacy%20Bus%20e-Zest.png)

  [CSR](https://blog.e-zest.com/csr)
  
  #### e-Zest Solutions supports Digital Pune Mission

  **Pune, India:** e-Zest Solutions, a leading digital technology innovation ...

  [Read more](https://blog.e-zest.com/csr/e-zest-solutions-supports-digital-pune-mission)

- [Work](https://www.e-zest.com/our-work)
- [Services](https://www.e-zest.com/our-services)
- [Insights](https://blog.e-zest.com)
- [Careers](https://www.e-zest.com/careers)
- [Enterprise Data](https://www.e-zest.com/enterprise-data-services)
- [Generative AI](https://www.e-zest.com/generative-ai)
- [Innovations](https://www.e-zest.com/innovations)
- [Healthcare](https://healthcare.e-zest.com)
- [About](https://www.e-zest.com/about-us)
- [Contact](https://www.e-zest.com/contact-us)

- [Blog](https://blog.e-zest.com/)
- [News](https://blog.e-zest.com/news)
- [CSR](https://blog.e-zest.com/csr)

- [![Linkedin Icon](https://blog.e-zest.com/hubfs/icons/linkedin_icon_white.svg)](https://www.linkedin.com/company/e-zest-solutions/)
- [![Twitter Icon](https://blog.e-zest.com/hubfs/twitter-logo-silhouette%20(5).svg)](https://twitter.com/ezest)
- [![Facebook Icon](https://blog.e-zest.com/hubfs/facebook-app-logo%20(4).svg)](https://www.facebook.com/61259256638)
- [![Instagram Icon](https://blog.e-zest.com/hubfs/instagram-logo%20(4).svg)](https://www.instagram.com/ezestsolutions/)
- [![Youtube Icon](https://blog.e-zest.com/hubfs/icons/youtube_icon_white.svg)](https://www.youtube.com/user/ezestcorporate)

[![Go to top icon](https://blog.e-zest.com/hubfs/AA%20Assets/top%20button.svg)](https://blog.e-zest.com/code-validations-using-static-review-library-in-magento#top)

Hit enter to search or ESC to close

Insights

e-Zest members share technology ideas to foster digital transformation.

- [Blog](https://blog.e-zest.com)
- [Whitepaper](https://blog.e-zest.com/whitepaper)
- [Playbook](https://blog.e-zest.com/playbook)
- [News](https://blog.e-zest.com/news)
- [Innovation](https://blog.e-zest.com/innovation)
- [Media Kit](https://www.e-zest.com/media-kit)

# Code validations using static-review library in Magento

[Shubh Sharma](https://blog.e-zest.com/author/shubh-sharma)  Oct 19, 2018

[Magento](https://blog.e-zest.com/topic/magento) [Magento 2.0](https://blog.e-zest.com/topic/magento-2-0)

- <https://www.linkedin.com/shareArticle?mini=true&url=https://blog.e-zest.com/code-validations-using-static-review-library-in-magento&title=&summary=&source=>
- <https://twitter.com/intent/tweet?source=https://blog.e-zest.com/code-validations-using-static-review-library-in-magento&text=Code%20validations%20using%20static-review%20library%20in%20Magento>
- <https://www.facebook.com/sharer/sharer.php?u=https://blog.e-zest.com/code-validations-using-static-review-library-in-magento>
- <https://www.instagram.com/ezestsolutions/?u=https://blog.e-zest.com/code-validations-using-static-review-library-in-magento>

**Introduction:**

Magento2 comes up with some advance tools and plugins, which are really useful for developers to track some common errors during development; I am going to introduce a small tutorial, which helps developers to validate PHP scripts before committing code to Git branch.

Below are some of the validations that can be validated using the described tutorial:

- LineEndingsReview
- PhpLeadingLineReview
- NoCommitTagReview
- PhpLintReview
- ComposerLintReview
- PhpCodeSnifferReview
- ComposerSecurityReview

**Requirements:**

- Git
- magento2 (2.2.5)
- sjparkinson/static-review (library)

**Installing library sjparkinson/static-review:**

To install it in your project, run **composer require sjparkinson/static-review** in the root of your magento2 installation directory

Command: **composer require sjparkinson/static-review

![static-review](https://blog.e-zest.com/hs-fs/hubfs/static-review.png?width=648&name=static-review.png)**  
**A Working Example:**

- First, we need to identify the action/observer which requires PHP script validation, So in our example we will validate and run phpunit whenever a developer committed the code in any branch from his local machine
- Action/Observer can register using Git hooks, If you’ve been using Git for more than a short length of time. you’ll hopefully have heard of Git hooks. There are hooks for pre- and post-commit, pre- and post-update, pre-push, pre-rebase, and so on. Using Static Review library, you can write Git hooks with PHP.
- To register a hook in Git using Static Review tool follow these steps:

**STEP1:**

Command: **php vendor/bin/static-review.php

![php vendor](https://blog.e-zest.com/hs-fs/hubfs/php%20vendor.png?width=600&name=php%20vendor.png)  
STEP2:**

Command: **php vendor/bin/static-review.php help hook:install

![4-1](https://blog.e-zest.com/hs-fs/hubfs/4-1.png?width=608&name=4-1.png)  
STEP3:**

Command: **php vendor/bin/static-review.php hook:install -f vendor/sjparkinson/static-review/hooks/static-review-pre-commit.php .git/hooks/pre-commit

![5-1](https://blog.e-zest.com/hs-fs/hubfs/5-1.png?width=618&name=5-1.png)**

- Hook has been registered successfully
- Commit your changes using Git commit command ‘git commit -m “your message” ’. This command automatically scans your changes against validations and displays the result on the screen (refer below screenshot)

![6-1](https://blog.e-zest.com/hs-fs/hubfs/6-1.png?width=614&name=6-1.png)  
There are many more ways to utilize static review library, we can create our own review rules based on the coding standards, and hopefully this small tutorial will help simplify the life of the developer.

- <https://twitter.com/intent/tweet?source=https://blog.e-zest.com/code-validations-using-static-review-library-in-magento&text=Code%20validations%20using%20static-review%20library%20in%20Magento>
- <https://www.facebook.com/sharer/sharer.php?u=https://blog.e-zest.com/code-validations-using-static-review-library-in-magento>
- <https://www.linkedin.com/shareArticle?mini=true&url=https://blog.e-zest.com/code-validations-using-static-review-library-in-magento&title=&summary=&source=>

### Similar Blog

[![How to setup Docker Container for Magento 2](https://blog.e-zest.com/hubfs/How%20to%20setup%20Docker%20Container%20for%20Magento%202.jpg) How to setup Docker Container for Magento 2 Docker is an application that allows us to manage multiple applications in the simplest way in the docker container. Docker ... By Rajesh Rathod Oct 15, 2021](https://blog.e-zest.com/how-to-setup-docker-container-for-magento2)

[![The Irreversible Train](https://blog.e-zest.com/hubfs/The%20Irreversible%20Train.jpg)](https://blog.e-zest.com/the-irreversible-train)

[The Irreversible Train](https://blog.e-zest.com/the-irreversible-train)

[Everything (strong acquisition but bear with me) is going to go digital from a future perspective, and](https://blog.e-zest.com/the-irreversible-train)[e-commerce](https://blog.e-zest.com/all-you-need-to-know-adopting-digital-commerce-in-2021) is a large ...

By Vanessa Grignon Apr 02, 2021

[![Containerized Magento Application Deployed on Azure Web App for Containers](https://blog.e-zest.com/hubfs/blog-files/Containerized%20Magento%20Application%20Deployed%20on%20Azure%20Web%20App%20for%20Containers-190530.png) Containerized Magento Application Deployed on Azure Web App for Containers Magento is an open source technology for e-Commerce platform. The platform makes it flexible and easy for merchants to control ... By Pramod Farate May 30, 2019](https://blog.e-zest.com/containerized-magento-application-deployed-on-azure-web-app-for-containers)

[![Get Set and Go! Magento Imagine 2019 is here](https://blog.e-zest.com/hubfs/blog-files/e-Zest%20Gold%20Sponsors%20for%20Magento%20Imagine%202019-190508C.png) Get Set and Go! Magento Imagine 2019 is here It is that time of the year, when every developer, evangelist, commerce innovator and marketers looking for their digital ... By Janki Sampat May 10, 2019](https://blog.e-zest.com/get-set-and-go-magento-imagine-2019-is-here)

[![Mark the date for Imagine 2019: May 13-15 at the Wynn Las Vegas!](https://blog.e-zest.com/hubfs/blog-files/e-Zest%20Gold%20Sponsors%20for%20Magento%20Imagine%202019-190508a.png) Mark the date for Imagine 2019: May 13-15 at the Wynn Las Vegas! We have been regulars at #MagentoImagine for the past eight years and we are absolutely thrilled to be part of Magento Imagine ... By Corporate May 07, 2019](https://blog.e-zest.com/mark-the-date-for-imagine-2019-may-13-15-at-the-wynn-las-vegas)

[![What is Magento Business Intelligence and why you need it?](https://blog.e-zest.com/hubfs/blog-files/What%20is%20Magento%20Business%20Intelligence%20and%20why%20you%20need%20it.png) What is Magento Business Intelligence and why you need it? Recently Magento has come up with a new feature Magento Business Intelligence (aka Magento BI). In this blog post, I will run you ... By Shubh Sharma Oct 03, 2018](https://blog.e-zest.com/what-is-magento-business-intelligence-and-why-you-need-it)

## Helping Organizations Thrive in the Digital Age

[Contact Us](https://www.e-zest.com/contact-us)

- [About](https://www.e-zest.com/about-us)
- [Services](https://www.e-zest.com/our-services)
- [Work](https://www.e-zest.com/our-work)
- [Insights](https://blog.e-zest.com/)
- [Healthcare](https://healthcare.e-zest.com/)
- [Accion Labs](https://www.accionlabs.com/)

- <https://www.linkedin.com/company/e-zest-solutions/>
- <https://twitter.com/ezest>
- <https://www.facebook.com/eZest/>
- <https://www.instagram.com/ezestsolutions/>
- <https://www.youtube.com/user/ezestcorporate>

- Dallas
- Detroit
- Hannover
- Vienna
- London
- Pune

 © 2025 e-Zest Solutions

- [Privacy Policy](https://www.e-zest.com/privacypolicy)
- [Cookie Policy](https://www.e-zest.com/cookie-policy)

 Contact us

 Contact us

e-Zest is a leading digital innovation partner for enterprises and technology companies that utilizes emerging technologies for creating engaging customers experiences. Being a customer-focused and technology-driven company, it always helps clients in crafting holistic business value for their software development efforts. It offers software development and consulting services for cloud computing, enterprise mobility, big data and analytics, user experience and digital commerce.