Magento 2 cURL

Following code get content from an external site using cURL.

 namespace PHPCodez\Layout\Block;
 class Footer extends \Magento\Framework\View\Element\Template {
 protected $_httpClientFactory;
 public function __construct(\Magento\Framework\View\Element\Template\Context $context,
 \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory) {
 $this->_httpClientFactory = $httpClientFactory;

public function getFooterContent() {
 $url = "";
 $client = $this->_httpClientFactory->create();
 return $response = $client->request(\Zend_Http_Client::POST)->getBody(); 

For more option you can check vendor\magento\framework\HTTP\Client\Curl.php

get() // for get request
makeRequest() // for make request
setOption() // set curl options

Magento 2 Remove Footer Links

You can remove Footer Links by adding the below line to layout xml.

<?xml version="1.0"?>
<page xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
 <referenceBlock name="footer_links" remove="true"/>
<referenceBlock name="cms_footer_links_container" remove="true" />

Magento 2 Factory Object

Factory Object is used to instantiate an object

The Factory class name is the name of Model class and append with the Factory word. So for our example, we will have TopicFactory class. You must not create this class. Magento will create it for you. Whenever Magento’s object manager encounters a class name that ends in the word ‘Factory’, it will automatically generate the Factory class in the var/generation folder if the class does not already exist. You will see the factory class in


To instantiate a model object we will use automatic constructor dependency injection to inject a factory object, then use factory object to instantiate the model object.

For example, we will call the model to get data in Block. We will create a Header block – PHPCodez\Layout\Block\Header.php with the following content.

 namespace PHPCodez\Layout\Block;
 class Header extends \Magento\Framework\View\Element\Template {
 protected $_headerContentFactory;
 public function __construct(\Magento\Framework\View\Element\Template\Context $context,
 \PHPCodez\Layout\Model\HeaderContentFactory $headerContentFactory) {
 $this->_headerContentFactory = $headerContentFactory;

public function getHeaderContent() {
 $headerContent = $this->_headerContentFactory->create();
 return $headerContent->process();

Here the block is calling the model function process().