Here is a tutorial on how to use the webmavens/laravel-faxage package in a Laravel project:
Prerequisites
- A Laravel project set up on your local development environment
- A Faxage account
- Composer installed on your system
Installation
composer require webmavens/laravel-faxage
This will install the package and its dependencies.
Next, you need to add the service provider and facade for the package in your config/app.php
file.
'providers' => [
// ...
Webmavens\Faxage\FaxageServiceProvider::class,
],
'aliases' => [
// ...
'Faxage' => Webmavens\Faxage\Facades\Faxage::class,
],
Configuration
Before you can use the package, you need to set up your Faxage credentials. You can do this by publishing the package’s configuration file and adding your credentials to the config/faxage.php
file.
To publish the configuration file, run the following command:
php artisan vendor:publish --provider="Webmavens\Faxage\FaxageServiceProvider"
This will create a faxage.php
file in the config
directory of your project. Open the file and add your Faxage username and password:
return [
'username' => 'your_faxage_username',
'password' => 'your_faxage_password',
];
Sending a Fax
Now that you have the package installed and configured, you can use it to send a fax.
First, use the Faxage
facade to create a new fax object:
$fax = Faxage::fax();
Next, set the recipient’s fax number and the file you want to send:
$fax->to('1234567890')->file('path/to/file.pdf');
Finally, send the fax using the send()
method:
$fax->send();
That’s it! You should now be able to send faxes using the webmavens/laravel-faxage package in your Laravel project.
Additional Options
The fax()
method also accepts an array of options as an argument. These options include:
to
: the recipient’s fax number (required)file
: the file to send (required)cover_page_text
: text to include on the cover pagepriority
: the priority of the fax (either “normal” or “high”)
For example, you can send a fax with a cover page and high priority like this:
$fax = Faxage::fax([
'to' => '1234567890',
'file' => 'path/to/file.pdf',
'cover_page_text' => 'This is the cover page text',
'priority' => 'high',
]);