Skip to content
This repository has been archived by the owner on Mar 11, 2019. It is now read-only.

the94air/slimo

Repository files navigation

slimo

A skelton for your slim app

Installation

  1. install with composer. Your PHP package manager.
composer create-project the94air/slimo [Project Name]
  1. And for using webpack (laravel-mix) just run
npm install
  1. Have fun!

Learn how to use

You can browse these links to find out more about each part of this skeleton

  1. Slim framework
  2. Laravel ORM (Eloquent) for communicating with the database.
  3. Dotenv for loading environment variables (.env).
  4. Twig for PHP template engine.
  5. Slim-Csrf for CSRF protection.
  6. SlimValidation & Respect\Validation for forms validation.
  7. Laravel Mix for assets compiling with wepack.
  8. swiftmailer for sending emails.

How to send mail

For that you will be able to add your configurations to the .env file.

# Using SMTP
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=example@gmail.com
MAIL_PASSWORD=secret
MAIL_ENCRYPTION=tls

# Or using Sendmail server
MAIL_DRIVER=sendmail
MAIL_SENDMAIL_PATH='/usr/sbin/sendmail -bs'

And after that you will be able to access the $mailer from your Routers and Controllers.

class MailController extends Controller
{
    public function index(Request $request, Response $response, $args)
    {
        $mailer = $this->mailer;

        // Create a message
        $message = (new \Swift_Message('Wonderful Subject'))
            ->setFrom(['john@doe.com' => 'John Doe'])
            ->setTo(['receiver@domain.org', 'other@domain.org' => 'A name'])
            ->setBody('Here is the message itself');

        // Send the message
        $result = $mailer->send($message);

        // returns `int(2)` on success
        var_dump($result);
    }
}

Attention

This package is forked from slender package thanks to Alex Garrett with more additional and useful packages. Feel free to add your own feature from the open source universe (Make a pull request).

This software does not have a license. All used packages has it's own license. And BTW... Laravel is a trademark of Taylor Otwell.