Download the PHP package douglasmariz/email-twig-pdf without Composer

On this page you can find all versions of the php package douglasmariz/email-twig-pdf. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package email-twig-pdf

email-twig-pdf

PHP Email Class: Biblioteca para enviar e-mail. "swiftmailer", "twig" e "html2pdf".

Email-Twig-PDF é uma classe de abstração para submissão de e-mail, gera PDF e usa Twig para renderizar o modelo.

Como usar

Configurações de arquivos e pastas

Verifique se os modelos existem no diretório base: "{DIRETORIO_BASE}/templates/email/{feature}/{fileName}".
Se não existir, crie o(s) modelo(s) com extensões {.html.twig} para enviar mensagens HTML e {.text.twig} para uma mensagem simples sem tags html.

Class EmailTwigPdf_Config

Você pode configurar um diretório base para armazenar os templates.
Ex: $config = new EmailTwigPdf_Config(['template_path' => __DIR__.'/your-path']);

OBS: Deve seguir a seguinte estrutura:
DIRETORIO_BASE
    templates
        email

Class EmailTwigPdf_Auth

Classe para colocar suas credenciais de acesso ao email do remetente.
Ex: 
    $credentials = [
            'userName' => 'user_name',
            'password' => 'password',
            'from' => '[email protected]',
            'fromName' => 'from_name',
            'smtp' => 'smtp.email.com',
            'port' => 465,
            'encryption' => 'ssl',
        ];
        $auth = new EmailTwigPdf_Auth($credentials);

Template de Exemplo

Já existe uma pasta chamada "templates" com um modelo default, de exemplo.

Uso simples da classe:

require_once('vendor/autoload.php');

use \DouglasMariz\Email\Twig\Pdf\EmailTwigPdf_Email;
use \DouglasMariz\Email\Twig\Pdf\EmailTwigPdf_Auth;
use \DouglasMariz\Email\Twig\Pdf\EmailTwigPdf_Config;

try {
    $email = new EmailTwigPdf_Email($auth, $config);
    $context = [
        'nome' => 'Usuário',
        'titulo' => 'Título',
        'mensagem' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.
                        Blanditiis cum debitis et expedita fugit hic iure laboriosam laudantium.',
    ];
    $result = $email->setTo('[email protected]', 'Nome Destinatário')
        ->setSubject('Assunto do email')
        ->setTemplateFile('pasta-arquivo', $context)
        ->setCssFile('pasta-arquivo')
        ->setDateHour() //Adiciona ao template a data e hora no formato pt_BR, apenas se existir no template as variáveis {{data}} e {{hora}}
        ->pdf()
        ->sendMail();

} catch (Exception $e) {
    echo $e->getMessage();
}

Úteis

$email->pdf(); // Para gerar um arquivo PDF e enviar como anexo ao email.
$email->setFileNamePdf(); // Define o nome para o arquivo PDF.
$email->setBlock(); // Define o BLOCO que será utilizado no template, caso esteja definido
    EX:
        {% if block == 'default' %}
            {% block default %}
                {{ content }}
            {% endblock %}
        {% endif %}

$email->showTemplateText(); // Renderiza na tela o template.
$email->showTemplateHtml(); // Renderiza na tela o template.

All versions of email-twig-pdf with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.0
twig/twig Version v2.5.0
swiftmailer/swiftmailer Version 6.1.2
spipu/html2pdf Version 5.2.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package douglasmariz/email-twig-pdf contains the following files

Loading the files please wait ....