Skip to content

Instantly share code, notes, and snippets.

@alnutile
Last active August 29, 2015 14:05
Show Gist options
  • Save alnutile/24292d551e004b36793f to your computer and use it in GitHub Desktop.
Save alnutile/24292d551e004b36793f to your computer and use it in GitHub Desktop.
Example Layout
  1. Example with you having a Namespace in your module / <--module root /src/Foo <--This is your namespace folder

This is now your composer

"require": {
    "php": ">=5.4.0",
    "someother/other_class": "4.2.*",
},

"autoload": {
    "psr-0": {
      "Foo": "src/"
    }
}
  1. You have not extra Namespaces in your module then your composer will not have any either. Basically the libraries you "require" will add them to composers autoload file.

Go look into vendor/autoload.php and click around

"require": {
    "php": ">=5.4.0",
    "someother/other_class": "4.2.*",
}
  1. You are extending a library This can be ideal

/ <--module root

/src/Foo/Bar.php

In that Bar.php file

<?php
namespace Foo;

class Bar extends OtherClass {
    
}

Now your composer.json looks like


"require": {
    "php": ">=5.4.0",
    "someother/other_class": "4.2.*",
},

"autoload": {
    "psr-0": {
      "Foo": "src/"
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment