im cofusing how to create a new instance of an object in ZF2. My class is called Clientela and i want to create a new instance of this class in another page, but im getting an error trying to do this.
My class is:
<?php
namespace Magento\Framework\Model\ResourceModel\Clientela;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Exception\AlreadyExistsException;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Model\ResourceModel\AbstractResource;
class Clientela{
private $id;
private $nome;
private $email;
public function __construct(){
}
public function getId(){
return $this->id;
}
public function setId($id){
$this->id = $id;
}
public function getNome(){
return $this->nome;
}
public function setNome($nome){
$this->nome = $nome;
}
public function getEmail(){
return $this->email;
}
public function setEmail($email){
$this->email = $email;
}
}
?>
and im trying to initialize in another page .php
use Magento\Framework\Model\ResourceModel\Clientela as Cli;
$cli = new Cli();
But its not working. Error:
Fatal error: Class 'Magento\Framework\Model\ResourceModel\Clientela' not found in /var/www/html/vendor/magento/module-contact/view/frontend/templates/form.phtml on line 20
How can i do that?
Cliinside your view?use Magento\Framework\Model\ResourceModel\Clientela\Clientela as Cli;. The way you create an object instance in ZF is no different to PHP.