2017 © Pedro Peláez
 

library module-tutorial

Tutorial for creating a reusable module

image

rayzor65/module-tutorial

Tutorial for creating a reusable module

  • Thursday, December 3, 2015
  • by adamsynnott1
  • Repository
  • 1 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Write a reusable module

This is an example and mini tutorial on how to create a module that you can pull in with composer. It would be a good idea to have a basic understanding of autoloading and namespaces prior to creating your module., (*1)

Writing the module

  • Copy this project into a new directory
  • Edit the composer.json with the details of your module
  • The autoload field means all the classes will be included under the specified namespace.
  • Tag your module, (*2)

    git tag 1.0.1, (*3)

    git push origin --tags, (*4)

Including the module

Update your project's composer file., (*5)

Specify where the repo is, (*6)

"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/rayzor65/module-tutorial" // Change this to your module
    }
]

Then add to require, (*7)

    "require": {
        "rayzor65/module-tutorial": "1.0.1" // Change this to your module
    }

Now you may you the class in your project like so, (*8)

use ModuleTutorial\MyModule\MyService;

class ProjectClass
{
    public function ProjectClassFunction()
    {
        // You can now use your autoloaded classes from the module
        $service = new MyService();
        $service->doSomething();
    }
}

Final steps

  • Make sure you have put your own README instructions

The Versions

03/12 2015

dev-master

9999999-dev

Tutorial for creating a reusable module

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

03/12 2015

1.0.4

1.0.4.0

Tutorial for creating a reusable module

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

03/12 2015

1.0.3

1.0.3.0

Tutorial for creating a reusable module

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

02/12 2015

1.0.2

1.0.2.0

Tutorial for creating a reusable module

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

02/12 2015

1.0.1

1.0.1.0

Tutorial for creating a reusable module

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

02/12 2015

1.0.0

1.0.0.0

Tutorial for creating a reusable module

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires