Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Disable Bundle Laravel Package

aferrandini/disable-bundle

Symfony bundle that adds annotations to disable controllers/actions immediately or within a time window (after/until/range). When disabled, it can show a custom message or redirect the request to another route.

View on GitHub
Deep Wiki
Context7

DisableBundle

This Bundle has been created to show how to create a custom Annotation in deSymfony 2013 Conference.

You will find more information about Annotations at Annotations: it’s not a part of my program, but it’s my program.

This bundle provides an easy way to disable an Action or a Controller. You will be able to disable directly, after a date/time, until a date/time or by a date/time range. You also be able to show a disabled message or redirect the request to another route.

Build Status SensioLabsInsight

Installation

Step 1: Install vendors

Symfony 2.0.x: bin/vendors.php method

If you're using the bin/vendors.php method to manage your vendor libraries, add the following entries to the deps in the root of your project file:

[FerrandiniDisableBundle]
    git=http://github.com/aferrandini/DisableBundle.git
    target=/bundles/Ferrandini/Bundle/DisableBundle

Next, update your vendors by running:

$ ./bin/vendors

Finally, add the following entry to your autoloader:

<?php
// app/autoload.php

$loader->registerNamespaces(array(
    // ...
    'Ferrandini'        => __DIR__.'/../vendor/bundles',
));

Symfony >=2.1.x: Composer

Composer is a project dependency manager for PHP. You have to list your dependencies in a composer.json file:

{
    "require": {
        "aferrandini/disable-bundle": "dev-master"
    }
}

To actually install DisableBundle in your project, download the composer binary and run it:

wget http://getcomposer.org/composer.phar
# or
curl -O http://getcomposer.org/composer.phar

php composer.phar install

Step 2: Enable the bundle

Finally, enable the bundle in the kernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...

        new Ferrandini\Bundle\DisableBundle\FerrandiniDisableBundle(),
    );
}

Usage

This Bundle provides an easy way to disable a Controller or an Action as you can see in the following examples.

Disabling a Controller

<?php

namespace Foo\Bundle\FooBundle\Controller;

use Ferrandini\Bundle\DisableBundle\Annotations\Disable;

/**
 * @Disable()
 */
class FooController {

}

Disabling an Action

<?php

namespace Foo\Bundle\FooBundle\Controller;

use Ferrandini\Bundle\DisableBundle\Annotations\Disable;

class FooController {

    /**
     * @Disable()
     */
    public function fooAction()
    {
        // ...
    }
}

Disabling with custom message

<?php

namespace Foo\Bundle\FooBundle\Controller;

use Ferrandini\Bundle\DisableBundle\Annotations\Disable;

/**
 * @Disable(message="This controller has been disabled with DisableBundle")
 */
class FooController {

}

Disabling by date/time

The date/time has to be defined as a PHP supported date and time format. You can see the supported formats in Supported Date and Time Formats

Disabling until a date/time

<?php

namespace Foo\Bundle\FooBundle\Controller;

use Ferrandini\Bundle\DisableBundle\Annotations\Disable;

/**
 * @Disable(until="2013-11-11 11:11")
 */
class FooController {

}

Disabling after a date/time

<?php

namespace Foo\Bundle\FooBundle\Controller;

use Ferrandini\Bundle\DisableBundle\Annotations\Disable;

/**
 * @Disable(after="2013-11-11 11:11")
 */
class FooController {

}

Disabling by date/time range

<?php

namespace Foo\Bundle\FooBundle\Controller;

use Ferrandini\Bundle\DisableBundle\Annotations\Disable;

/**
 * @Disable(until="2013-06-11", after="2013-11-11")
 */
class FooController {

}

Disabling and redirect to route

The route should be a defined route name in the routing configuration.

<?php

namespace Foo\Bundle\FooBundle\Controller;

use Ferrandini\Bundle\DisableBundle\Annotations\Disable;

/**
 * @Disable(redirect="_welcome")
 */
class FooController {

}

Disabling with a custom response status code

<?php

namespace Foo\Bundle\FooBundle\Controller;

use Ferrandini\Bundle\DisableBundle\Annotations\Disable;

/**
 * @Disable(statusCode=404)
 */
class FooController {

}
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony
spatie/flare-daemon-runtime