# phpman > perldoc > Moo::Role

## NAME
    [Moo::Role](https://www.chedong.com/phpMan.php/perldoc/Moo%3A%3ARole/markdown) - Minimal Object Orientation support for Roles

## SYNOPSIS
      package [My::Role](https://www.chedong.com/phpMan.php/perldoc/My%3A%3ARole/markdown);

      use [Moo::Role](https://www.chedong.com/phpMan.php/perldoc/Moo%3A%3ARole/markdown);
      use strictures 2;

      sub foo { ... }

      sub bar { ... }

      has baz => (
        is => 'ro',
      );

      1;

    And elsewhere:

      package [Some::Class](https://www.chedong.com/phpMan.php/perldoc/Some%3A%3AClass/markdown);

      use Moo;
      use strictures 2;

      # bar gets imported, but not foo
      with '[My::Role](https://www.chedong.com/phpMan.php/perldoc/My%3A%3ARole/markdown)';

      sub foo { ... }

      1;

## DESCRIPTION
    "[Moo::Role](https://www.chedong.com/phpMan.php/perldoc/Moo%3A%3ARole/markdown)" builds upon [Role::Tiny](https://www.chedong.com/phpMan.php/perldoc/Role%3A%3ATiny/markdown), so look there for most of the documentation on how this
    works (in particular, using "[Moo::Role](https://www.chedong.com/phpMan.php/perldoc/Moo%3A%3ARole/markdown)" also enables strict and warnings). The main addition
    here is extra bits to make the roles more "Moosey;" which is to say, it adds "has".

## IMPORTED SUBROUTINES
    See "IMPORTED SUBROUTINES" in [Role::Tiny](https://www.chedong.com/phpMan.php/perldoc/Role%3A%3ATiny/markdown) for all the other subroutines that are imported by this
    module.

  has
      has attr => (
        is => 'ro',
      );

    Declares an attribute for the class to be composed into. See "has" in Moo for all options.

## CLEANING UP IMPORTS
    [Moo::Role](https://www.chedong.com/phpMan.php/perldoc/Moo%3A%3ARole/markdown) cleans up its own imported methods and any imports declared before the "use [Moo::Role](https://www.chedong.com/phpMan.php/perldoc/Moo%3A%3ARole/markdown)"
    statement automatically. Anything imported after "use [Moo::Role](https://www.chedong.com/phpMan.php/perldoc/Moo%3A%3ARole/markdown)" will be composed into consuming
    packages. A package that consumes this role:

      package [My::Role::ID](https://www.chedong.com/phpMan.php/perldoc/My%3A%3ARole%3A%3AID/markdown);

      use [Digest::MD5](https://www.chedong.com/phpMan.php/perldoc/Digest%3A%3AMD5/markdown) qw(md5_hex);
      use [Moo::Role](https://www.chedong.com/phpMan.php/perldoc/Moo%3A%3ARole/markdown);
      use [Digest::SHA](https://www.chedong.com/phpMan.php/perldoc/Digest%3A%3ASHA/markdown) qw(sha1_hex);

      requires 'name';

      sub as_md5  { my ($self) = @_; return md5_hex($self->name);  }
      sub as_sha1 { my ($self) = @_; return sha1_hex($self->name); }

      1;

    ..will now have a "$self->sha1_hex()" method available to it that probably does not do what you
    expect. On the other hand, a call to "$self->md5_hex()" will die with the helpful error message:
    "Can't locate object method "md5_hex"".

    See "CLEANING UP IMPORTS" in Moo for more details.

## SUPPORT
    See Moo for support and contact information.

## AUTHORS
    See Moo for authors.

## COPYRIGHT AND LICENSE
    See Moo for the copyright and license.

