Skip to main content
added 1 character in body; edited title
Source Link
Rafael Corrêa Gomes
  • 13.7k
  • 14
  • 91
  • 181

How to override a zendZend class?

I want to override a Zend class (Zend_Date). In magentoMagento 1, I used to put Date.php in app/code/community/Zend and Magento itself used to do the rest. But now, there is no such directory. How can I override that class?


**Edit:** I installed [Magento_SampleNewPage][1] module and it shows `Hello world!` message properly when I go to `http://domain.com/newpage`. I edited `composer.json` and added my `Date.php` to it:
{
  "name": "magento/sample-module-newpage",
  "description": "A Magento 2 module that creates a new page",
  "type": "magento2-module",
  "version": "1.0.0",
  "license": [
    "OSL-3.0",
    "AFL-3.0"
  ],
  "require": {
    "php": "~5.5.0|~5.6.0|~7.0.0",
    "magento/framework": "~100.0"
  },
  "autoload": {
    "files": [ "Zend/Date.php" , "registration.php"  ],
    "psr-4": {
      "Magento\\SampleNewPage\\": ""
    }
  }
}

But still, it doesn't work. When I instantiate a new Zend_Date , it's from vendor/magentoMagento/zendframework1/library/Zend/Date.php not my Zend_Date.

How to override a zend class

I want to override a Zend class (Zend_Date). In magento 1, I used to put Date.php in app/code/community/Zend and Magento itself used to do the rest. But now, there is no such directory. How can I override that class?


**Edit:** I installed [Magento_SampleNewPage][1] module and it shows `Hello world!` message properly when I go to `http://domain.com/newpage`. I edited `composer.json` and added my `Date.php` to it:
{
  "name": "magento/sample-module-newpage",
  "description": "A Magento 2 module that creates a new page",
  "type": "magento2-module",
  "version": "1.0.0",
  "license": [
    "OSL-3.0",
    "AFL-3.0"
  ],
  "require": {
    "php": "~5.5.0|~5.6.0|~7.0.0",
    "magento/framework": "~100.0"
  },
  "autoload": {
    "files": [ "Zend/Date.php" , "registration.php"  ],
    "psr-4": {
      "Magento\\SampleNewPage\\": ""
    }
  }
}

But still it doesn't work. When I instantiate a new Zend_Date , it's from vendor/magento/zendframework1/library/Zend/Date.php not my Zend_Date.

How to override a Zend class?

I want to override a Zend class (Zend_Date). In Magento 1, I used to put Date.php in app/code/community/Zend and Magento itself used to do the rest. But now, there is no such directory. How can I override that class?


**Edit:** I installed [Magento_SampleNewPage][1] module and it shows `Hello world!` message properly when I go to `http://domain.com/newpage`. I edited `composer.json` and added my `Date.php` to it:
{
  "name": "magento/sample-module-newpage",
  "description": "A Magento 2 module that creates a new page",
  "type": "magento2-module",
  "version": "1.0.0",
  "license": [
    "OSL-3.0",
    "AFL-3.0"
  ],
  "require": {
    "php": "~5.5.0|~5.6.0|~7.0.0",
    "magento/framework": "~100.0"
  },
  "autoload": {
    "files": [ "Zend/Date.php" , "registration.php"  ],
    "psr-4": {
      "Magento\\SampleNewPage\\": ""
    }
  }
}

But still, it doesn't work. When I instantiate a new Zend_Date , it's from vendor/Magento/zendframework1/library/Zend/Date.php not my Zend_Date.

Tweeted twitter.com/StackMagento/status/777432419104333824
added 996 characters in body
Source Link
undone
  • 261
  • 1
  • 4
  • 18

I want to override a Zend class (Zend_Date). In magento 1, I used to put Date.php in app/code/community/Zend and Magento itself used to do the rest. But now, there is no such directory. How can I override that class?


**Edit:** I installed [Magento_SampleNewPage][1] module and it shows `Hello world!` message properly when I go to `http://domain.com/newpage`. I edited `composer.json` and added my `Date.php` to it:
{
  "name": "magento/sample-module-newpage",
  "description": "A Magento 2 module that creates a new page",
  "type": "magento2-module",
  "version": "1.0.0",
  "license": [
    "OSL-3.0",
    "AFL-3.0"
  ],
  "require": {
    "php": "~5.5.0|~5.6.0|~7.0.0",
    "magento/framework": "~100.0"
  },
  "autoload": {
    "files": [ "Zend/Date.php" , "registration.php"  ],
    "psr-4": {
      "Magento\\SampleNewPage\\": ""
    }
  }
}

But still it doesn't work. When I instantiate a new Zend_Date , it's from vendor/magento/zendframework1/library/Zend/Date.php not my Zend_Date.

I want to override a Zend class (Zend_Date). In magento 1, I used to put Date.php in app/code/community/Zend and Magento itself used to do the rest. But now, there is no such directory. How can I override that class?

I want to override a Zend class (Zend_Date). In magento 1, I used to put Date.php in app/code/community/Zend and Magento itself used to do the rest. But now, there is no such directory. How can I override that class?


**Edit:** I installed [Magento_SampleNewPage][1] module and it shows `Hello world!` message properly when I go to `http://domain.com/newpage`. I edited `composer.json` and added my `Date.php` to it:
{
  "name": "magento/sample-module-newpage",
  "description": "A Magento 2 module that creates a new page",
  "type": "magento2-module",
  "version": "1.0.0",
  "license": [
    "OSL-3.0",
    "AFL-3.0"
  ],
  "require": {
    "php": "~5.5.0|~5.6.0|~7.0.0",
    "magento/framework": "~100.0"
  },
  "autoload": {
    "files": [ "Zend/Date.php" , "registration.php"  ],
    "psr-4": {
      "Magento\\SampleNewPage\\": ""
    }
  }
}

But still it doesn't work. When I instantiate a new Zend_Date , it's from vendor/magento/zendframework1/library/Zend/Date.php not my Zend_Date.

Source Link
undone
  • 261
  • 1
  • 4
  • 18

How to override a zend class

I want to override a Zend class (Zend_Date). In magento 1, I used to put Date.php in app/code/community/Zend and Magento itself used to do the rest. But now, there is no such directory. How can I override that class?