Download the PHP package brunocfalcao/zahper without Composer

On this page you can find all versions of the php package brunocfalcao/zahper. 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 zahper

About Zahper

Zahper is a Laravel on-steroids Mailable that lets you create beautiful cross-browser email newsletters using MJML.

Why Zahper

Zahper will solve you these problems:

Zahper Features

You get all of this out-of-the-box:

Installation

You can install Zahper via composer using this command:

The package will automatically register the service provider (using auto-discover).

Next step is to publish your zahper.php configuration.

Final step is to install your mjml.io api keys in your .ENV configuration.

:point_right: You need to register for the Api keys for your MJML api application here. It's free.

No time to wait?

After having your api keys in your .ENV file, just do this for a quick email demo:

Run the following artisan command:

Navigate in your local laravel app to the url /zahper/demo. Et voilá, you should see a mailable demo.

How it works

Zahper uses the power of MJML syntax to render an HTML email that will be cross-browser compatible. To do this, you first need to learn MJML, and believe me it's pretty straight forward. You can check the documentation here.

Additionally it leverages the full features of the Laravel Mailable that you can use. So, it's 100% compatible with any Mailable-based codebase you did.

How to use Zahper

  1. Start by creating your zahper mailable using the following example:

This command will create your new mailable in the app\Mail folder.

  1. Inside your zahper mailable, you have the following methods:

The $cache static attribute will allow you to cache your MJML compiled view, so in case you have 500 emails to be sent, you don't call the MJML api 500 times. You should make it false until you tested your newsletter and finally turn it true when you decide to use it in your website. More about the cache later in this readme.

This is where the magic happens. You will write your MJML and Zahper will call the MJML api to compile it to a view. As a quick example (more examples later in this readme) the following MJML:

is written in Zahper like this:

and the final method:

Is used to configure your Mailable "from" recipient and the subject.

:point_up: All the Laravel Mailable features are available for you, except the "build" method. As example, you can pass public attributes, and they will also be available in the MJML rendered view!

How do you code the MJML

Coding your MJML is made in a very natural way.

  1. You create the component:

  2. You then add all your attributes in 2 ways, as example:

Let's see another examples, so you can learn it better:

is written like:

The coding way is "natural". Meaning you create your component, then if you want to add a child component you use the ->with(), and if you want to pass properties, you just keep adding them as methods. You just need to respect that attribute name convention, like "background-color" should be ->backgroundColor(). And that's it ! Zahper then converts it to a pure MJML, calls the MJML Api to convert it to a blade view, and calls the ->build() Mailable method!

:question: What happens if you want to code 2 columns?

Simple. You have a ->parent() method that will point one level up in the MJML hierarchy :blush:

is written like:

Caching strategy

Zahper needs to have a caching strategy since when you are sending a high volume of emails we cannot just call the MJML Api to convert the same MJML over and over. You can suddenly see your MJML Api account blocked in case spikes occur. So, Zahper allows you to cache your blade view so the next time the same Mailable class is called it doesn't recompile the mjml, but just uses the cached view content.

Things you need to pay attention

Activating the Zahper Mailable cache

The way you turn on, or off the Mailable cache is in your generated Zahper Mailable, in the construct() method:

:exclamation: Keep it off until you have your newsletter structure all fine tuned. Then you turn it on and the MJML Api, for this Mailable, will not be called again until you turn it on again.

Using dynamic values on your Zahper Mailable

Let's say you want to have, for instance, a dynamic URL in a Button href attribute with a distinct user id per email.

You then should write it this way:

:exclamation: If you write it this way below, the user id will get cached. So you will send 500 emails, to 500 recipients, all of them with the same user id!

View in Browser

For each sent email, Zahper stores a copy in your storage folder with a distinct UUID. You can access this UUID only during the lifecycle of the Mailable. After that it's discarded and re-generated again.

The UUID is accessed in your mailable via:

You can also configure the route and action called directly in the zahper configuration file.

Also, you have a helper that will generate the full url for you, so you can use it on your MJML code:

Unsubscribe

Like the View in Browser, the UUID is also used for the unsubscribe. Zahper will have a default route that you can use, but the action doesn't do more than calling an event. So it's up to you to inject a listener.

ZahpController@unsubscribe action:

Current development status

Contributing

At the moment you don't need to contribute since Zahper is still in early-production release. You can already use it in your production website but still pay attention to my repository for issues that might impact you.

License

Zahper is open-sourced software licensed under the MIT license.

How to follow me

You can follow my work on twitter, @brunocfalcao. :)


All versions of zahper with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3||^8.0
illuminate/support Version ^6.0||^7.0||^8.0||^9.0
guzzlehttp/guzzle Version ^6.0
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 brunocfalcao/zahper contains the following files

Loading the files please wait ....