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

Reserved Names Bundle Laravel Package

alister/reserved-names-bundle

View on GitHub
Deep Wiki
Context7

ReservedNamesBundle - alister/reserved-names-bundle

A bundled service to clean, and check, a given username against an (extensible) list of reserved words/usernames.

Note: This DOES NOT validate usernames. That should happen (and potentially disallow names) before getting to this stage.

Installation and use

  1. Add to app/AppKernel.php

    $bundles = array(
        new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
        // ... many others
    
        new Alister\ReservedNamesBundle\AlisterReservedNamesBundle(),
    );
    
  2. Add to app/config/config.yml

    alister_reserved_names:
        names:
            # These keys will be lower-cased
            - myname
            - myothername
            - alister
            - private
    
  3. Use

    $username = 'myname_123';
    $reserved = $this->container->get('alister_reserved_names.check');
    if ($reserved->isReserved($username)) {
        echo "{$username} is reserved";
    }
    
  4. Services provided:

  • alister_reserved_names.check
    • Check username does not match a reserved name, before or after calling @cleanusername
    • @see Alister\ReservedNamesBundle\Services\ReservedNames
    • The code also strips off trailing 's', and then additional noise characters (digits, -, _) for a final test against the reserved names
  • alister_reserved_names.cleanusername
    • remove 'noise characters' around the given username
    • EG: myname_123 becomes myname
    • @see Alister\ReservedNamesBundle\Services\CleanUserNames

Included tests

Testing is done with the classes directly, and also via a container, to test the service initialisation. This also allows a check for the 'local reservations' - extra names that can be defined in the local application. The container-based test includes a micro-application to build the container, and so run the full test. How to create a test setup for a local test of the service.

@todo

Make a validator (from existing code) and put into this bundle, with tests and examples See: http://stackoverflow.com/questions/7004601/symfony2-testing-entity-validation-constraints

Badges

Build Status SensioLabsInsight Scrutinizer Code Quality

Latest Stable Version Total Downloads Latest Unstable Version License

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.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle