This package makes it easy to add early access mode to your existing application.

Overview

Laravel Early Access logo

This package makes it easy to add early access mode to your existing application. This is useful for when you want to launch a product and need to gather the email addresses of people who want early access to the application.

Take a look at contributing.md to see a to do list.

⚠️ This version supports Laravel 6 and above. Use version 1.x if you require Laravel 5 support.

Installation

Via Composer

To install via composer, run the following command in the root of your Laravel application:

$ composer require neo/laravel-early-access

Register the middleware Neo\EarlyAccess\Http\Middleware\CheckForEarlyAccessMode at the bottom of your web group middleware in app/Http/Middleware/Kernel.php.

<?php
// [...]

'web' => [
    \App\Http\Middleware\EncryptCookies::class,

    // [...]

    \Neo\EarlyAccess\Http\Middleware\CheckForEarlyAccessMode::class,
],

// [...]

Next, add/update the MAIL_* keys in your .env file. Make sure to include MAIL_FROM_* keys as it is required when sending welcome or goodbye emails to subscribers.

Also, you can optionally add the following environment variables to your .env file:

EARLY_ACCESS_ENABLED=true
EARLY_ACCESS_URL="/early-access"
EARLY_ACCESS_LOGIN_URL="/login"
EARLY_ACCESS_TWITTER_HANDLE=NeoIghodaro
EARLY_ACCESS_VIEW="early-access::index"
EARLY_ACCESS_SERVICE_DRIVER=database
EARLY_ACCESS_SERVICE_DB_TABLE=subscribers

Now migrate the required tables:

$ php artisan migrate

And publish the required assets:

$ php artisan vendor:publish --provider="Neo\EarlyAccess\EarlyAccessServiceProvider"

This will make the config, migrations, views, and assets available inside your applications directory so you can customise them.

TIP: You can append the --tag=assets flag to publish only the asset files which is required. Other available tag values are: config, translations, migrations, views and assets.

To activate early access, you can do either of the following:

  • Run the command $ php artisan early-access --activate
  • Set the EARLY_ACCESS_ENABLED to true in your .env file

TIP: Using the artisan command allows you to add IP addresses that are allowed to bypass the early access screen altogether.

$ php artisan early-access --allow=127.0.0.1 --allow=0.0.0.0

Note that logged in users will also bypass the early access screen.

Configuration

$ php artisan vendor:publish --provider="Neo\EarlyAccess\EarlyAccessServiceProvider" --tag=config

Configuration options

  • enabled - Sets whether the mode is enabled or not. In terms of priority, this is the last thing that is checked to see if the early access screen should be shown. Login status is checked, then artisan command status is checked, then this value is checked. default: false

  • url - The URL the early access screen will be shown at. The client will be redirected to this URL if they do not have access and the mode is enabled. You can set the value to / or any other existing routes. default: /early-access

  • login_url - The URL to your application's login page. This URL will automatically be bypassed even if early access mode is turned on. default: /login

  • twitter_handle - This is used when sending subscription confirmation via email. The user will have the option to tweet with the handle you specify tagged.

  • view - The early access screen view to be loaded. You can publish the views and customise it, or leave the default. default: early-access::index.

  • service - This is the subscription driver. See below for how to create your own driver. default: database.

  • services.database.table_name - The database table name. This is useful is you want to change the name of the database table. You need to do this before you run the migration though. default: subscribers

  • notifications - The default notification classes. You can use your own notification classes if you would like to change how users will be notified when they subscribe or unsubscribe.

Using / or an existing route as the early access URL

To use / or an existing route in your application as the early access URL, you need to do the following:

First, register the service provider manually below the App\Providers\RouteServiceProvider::class in config/app.php.

<?php

return [

    'providers' => [

        // [...]

        App\Providers\RouteServiceProvider::class,
        Neo\EarlyAccess\EarlyAccessServiceProvider::class,

        // [...]

    ],

    // [...]
];

Next, open your composer.json file and add the package in the dont-discover array:

// [...]

"laravel": {
    "dont-discover": [
        "neo/laravel-early-access"
    ]
},

// [...]

Now run composer dump-autoload -o and it should work.

Creating your own subscription service driver

By default, there is a database driver that manages all the users. You can decide to create your own driver though for other services like Mailchimp etc. (If you do, please consider submitting a PR with the driver).

To get started, you need to create a new class that implements the service provider class:

<?php

namespace App\Services\SubscriptionServices;

use Neo\EarlyAccess\Contracts\Subscription\SubscriptionProvider;

class MailchimpService implements SubscriptionProvider
{
    public function add(string $email, string $name = null): bool
    {
        // Implement adding a new subscriber...
    }

    public function remove(string $email): bool
    {
        // Implement removing a subscriber...
    }

    public function verify(string $email): bool
    {
        // Implement verifying a subscriber
    }

    /**
     * @return \Neo\EarlyAccess\Subscriber|false
     */
    public function findByEmail(string $email)
    {
        // Implement returning a subscriber from email
    }
}

Next, register your service in the register method of your app/Providers/AppServiceProvider class:

<?php

// [...]

$this->app->bind('early-access.mailchimp', function () {
    return new \App\Services\SubscriptionServices\MailchimpService;
});

// [...]

NOTE: Leave the early-access. namespace. It is required. Just append the name of your service to the namespace as seen above.

Next, go to your published configuration and change the service driver from database to mailchimp. That's all.

Change log

Please see the changelog for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email author email instead of using the issue tracker.

Credits

License

Please see the license file for more information.

You might also like...
Text-mode interface for git

Tig: text-mode interface for Git What is Tig? Tig is an ncurses-based text-mode interface for git. It functions mainly as a Git repository browser, bu

A plugin simplify 1v1 mode for Pocketmine-MP!

A plugin simplify 1v1 mode for Pocketmine-MP!

A simple but scalable FFA Practice Core featuring one Game Mode & Vasar PvP aspects.
A simple but scalable FFA Practice Core featuring one Game Mode & Vasar PvP aspects.

A simple but scalable FFA Practice Core featuring one Game Mode & Vasar PvP aspects. An example of this Plugin can be found in-game at ganja.bet:19132!

PHP package to make your objects strict and throw exception when you try to access or set some undefined property in your objects.

📢 Yell PHP package to make your objects strict and throw exception when you try to access or set some undefined property in your objects. Requirement

The Workflow Package add Drag & Drop Workflows to your Laravel Application.
The Workflow Package add Drag & Drop Workflows to your Laravel Application.

Workflows add Drag & Drop automation's to your Laravel application. The Workflow Package adds Drag & Drop Workflows to your Laravel Application. A Wor

Guest to Customer for Magento2 - Quickly and easily convert existing guest checkout customers to registered customers.
Guest to Customer for Magento2 - Quickly and easily convert existing guest checkout customers to registered customers.

Guest to Customer for Magento 2.0 For Magento 2.0.x, 2.1.x, 2.2.x, 2.3.x and 2.4.x In general E-commerce, shoppers do not like to create an account du

A Bayesian average is a method of estimating the mean of a population using outside information, especially a pre-existing belief, which is factored into the calculation
A Bayesian average is a method of estimating the mean of a population using outside information, especially a pre-existing belief, which is factored into the calculation

A Bayesian average is a method of estimating the mean of a population using outside information, especially a pre-existing belief, which is factored into the calculation.

This package is used to validate the telephone numbers of the countries taken into account. It also makes it possible to verify that a number is indeed a number of an operator X

phone-number-checker This package is used to validate the telephone numbers of the countries taken into account. It also makes it possible to verify t

Formcreator is a plugin which allow creation of custom forms of easy access
Formcreator is a plugin which allow creation of custom forms of easy access

Formcreator is a plugin which allow creation of custom forms of easy access. At the same time, the plugin allow the creation of one or more tickets when the form is filled.

Comments
  • Add brand new logo to the project

    Add brand new logo to the project

    Following your request in the tweet: http://twitter.com/NeoIghodaro/status/1180935261347340288

    Here it is your brand new logo… I've decided to maintain the trend of unDraw to match the package itself. Hope you like it! 😄

    image

    opened by caneco 4
  • Declare support for PHP 8.

    Declare support for PHP 8.

    opened by mattsims 1
  • Bump dependency Versions to Support Laravel 6

    Bump dependency Versions to Support Laravel 6

    Summary of Changes

    • Change Versions of dependencies to Support Laravel 6.
    • Modified Tests to Properly implement new PHP typed returns like:
    protected function setUp() {}
    

    to

    protected function setUp():void {}
    

    Test Instructions

    Install on a Laravel 5 project and then on a Laravel 6 Project

    Expected Outcome

    Should install on both a Laravel 5 Project and a Laravel 6 Project

    opened by bosunski 0
  • Install error from dependency

    Install error from dependency

    When attempting to install version 1.1 of this package on laravel/framework v6.12.0, the package is not installable. I'm not an expert in this, but it seems that illuminate/support requires v1.x.x of nesbot/carbon but laravel/framework needs v2.x.x of nesbot/carbon. Additionally, I believe that illuminate/support was removed and cannot be installed alongside with laravel/framework v6.12.0.

    I can post a minor part of composer install logs of this but this seems to be reproducible by making a new laravel v6.12.0 project and trying to install the package. I've also tried to downgrade to a few earlier versions of laravel/framework, but it still does not install

    Thanks!

    opened by alvin8t 2
Releases(v2.0.3)
Owner
Neo
Lead Software Engineer @deinebaustoffe
Neo
Add scalar type hints and return types to existing PHP projects using PHPDoc annotations

PHPDoc to Type Hint Archived! This repository is now archived. Consider using PHP CS Fixer (and especially the phpdoc_to_param_type and phpdoc_to_retu

Kévin Dunglas 228 May 22, 2022
Adds a compact "easy-sort" mode to Repeater and Repeater Matrix, making those fields easier to sort when there are a large number of items.

Repeater Easy Sort Adds a compact "easy-sort" mode to Repeater and Repeater Matrix, making those fields easier to sort when there are a large number o

Robin Sallis 3 Oct 10, 2021
ConFOMO is a simple tool that makes it easy to track your friends at conferences.

Connecting your online community with the real world, one conference at a time. Built in 4 hours to help me track who I wanted to meet at Laracon 2014

Tighten 74 Jul 20, 2022
This package is considered feature-complete, and is now in security-only maintenance mode

laminas-soap This package is considered feature-complete, and is now in security-only maintenance mode, following a decision by the Technical Steering

Laminas Project 46 Dec 18, 2022
Laravel Blog Package. Easiest way to add a blog to your Laravel website. A package which adds wordpress functionality to your website and is compatible with laravel 8.

Laravel Blog Have you worked with Wordpress? Developers call this package wordpress-like laravel blog. Give our package a Star to support us ⭐ ?? Inst

Binshops 279 Dec 28, 2022
RRR makes structured data for WordPress really rich, and really easy.

Really Rich Results - JSON-LD Structured Data (Google Rich Results) for WordPress Search engines are putting more weight on structured data than ever

Pagely 22 Dec 1, 2022
PHP bundle which makes array traversing / inserting dead easy.

XTraverse.php This bundle makes it dead easy to traverse through nested arrays/objects in PHP. Installation Via Composer composer require phiil/xtrave

Philipp Martini 2 Feb 12, 2022
A game-mode for Minecraft: Bedrock Edition

HardCoreFactions This is an unpaid commission that was only released for educational purposes, consider using it as a reference rather than having it

Doge 3 Sep 8, 2021
A new plugin like EconomyAPI but with a different mode

A new plugin like EconomyAPI but with a different mode

null 1 Dec 13, 2021
Textpattern-for-Panic-Coda - A Textpattern CMS mode for Panic Coda

Textpattern elements for Panic Coda 2 Handy elements for use with Panic Coda 2 on a Mac when authoring files for the Textpattern CMS. This repository

Phil Wareham 8 Jun 26, 2017