Skip to content

Commit

Permalink
Remove fenced blocks in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Feb 29, 2012
1 parent 0e6cf61 commit 605fae4
Show file tree
Hide file tree
Showing 7 changed files with 211 additions and 275 deletions.
14 changes: 5 additions & 9 deletions doc/00-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ You decide to use [monolog](https://github.com/Seldaek/monolog). In order to
add it to your project, all you need to do is create a `composer.json` file
which describes the project's dependencies.

```json
{
"require": {
"monolog/monolog": "1.0.*"
{
"require": {
"monolog/monolog": "1.0.*"
}
}
}
```

We are simply stating that our project requires the `monolog/monolog` package,
any version beginning with `1.0`.
Expand All @@ -58,8 +56,6 @@ This will download monolog and dump it into `vendor/monolog/monolog`.
After this you can just add the following line to your bootstrap code to get
autoloading:

```php
require 'vendor/.composer/autoload.php';
```
require 'vendor/.composer/autoload.php';

That's all it takes to have a basic setup.
38 changes: 14 additions & 24 deletions doc/01-basic-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,11 @@ The first (and often only) thing you specify in `composer.json` is the
`require` key. You're simply telling composer which packages your project
depends on.

```json
{
"require": {
"monolog/monolog": "1.0.*"
{
"require": {
"monolog/monolog": "1.0.*"
}
}
}
```

As you can see, `require` takes an object that maps package names to versions.

Expand Down Expand Up @@ -141,32 +139,26 @@ naming standard, composer generates a
`vendor/.composer/autoload.php` file for autoloading. You can simply include
this file and you will get autoloading for free.

```php
require 'vendor/.composer/autoload.php';
```
require 'vendor/.composer/autoload.php';

This makes it really easy to use third party code, because you only
have to add one line to `composer.json` and run `install`. For monolog, it
means that we can just start using classes from it, and they will be
autoloaded.

```php
$log = new Monolog\Logger('name');
$log->pushHandler(new Monolog\Handler\StreamHandler('app.log', Logger::WARNING));
$log = new Monolog\Logger('name');
$log->pushHandler(new Monolog\Handler\StreamHandler('app.log', Logger::WARNING));

$log->addWarning('Foo');
```
$log->addWarning('Foo');

You can even add your own code to the autoloader by adding an `autoload` field
to `composer.json`.

```json
{
"autoload": {
"psr-0": {"Acme": "src/"}
{
"autoload": {
"psr-0": {"Acme": "src/"}
}
}
}
```

This is a mapping from namespaces to directories. The `src` directory would be
in your project root. An example filename would be `src/Acme/Foo.php`
Expand All @@ -179,10 +171,8 @@ Including that file will also return the autoloader instance, so you can store
the return value of the include call in a variable and add more namespaces.
This can be useful for autoloading classes in a test suite, for example.

```php
$loader = require 'vendor/.composer/autoload.php';
$loader->add('Acme\Test', __DIR__);
```
$loader = require 'vendor/.composer/autoload.php';
$loader->add('Acme\Test', __DIR__);

> **Note:** Composer provides its own autoloader. If you don't want to use
that one, you can just include `vendor/.composer/autoload_namespaces.php`,
Expand Down
52 changes: 22 additions & 30 deletions doc/02-libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ libraries is that your project is a package without a name.
In order to make that package installable you need to give it a name. You do
this by adding a `name` to `composer.json`:

```json
{
"name": "acme/hello-world",
"require": {
"monolog/monolog": "1.0.*"
{
"name": "acme/hello-world",
"require": {
"monolog/monolog": "1.0.*"
}
}
}
```

In this case the project name is `acme/hello-world`, where `acme` is the
vendor name. Supplying a vendor name is mandatory.
Expand All @@ -36,11 +34,9 @@ the repository is able to infer the version from elsewhere.

If you do want to specify it explicitly, you can just add a `version` field:

```json
{
"version": "1.0.0"
}
```
{
"version": "1.0.0"
}

However if you are using git, svn or hg, you don't have to specify it.
Composer will detect versions as follows:
Expand Down Expand Up @@ -105,14 +101,12 @@ project locally. We will call it `acme/blog`. This blog will depend on `acme
this by creating a new `blog` directory somewhere, containing a
`composer.json`:

```json
{
"name": "acme/blog",
"require": {
"acme/hello-world": "dev-master"
{
"name": "acme/blog",
"require": {
"acme/hello-world": "dev-master"
}
}
}
```

The name is not needed in this case, since we don't want to publish the blog
as a library. It is added here to clarify which `composer.json` is being
Expand All @@ -122,19 +116,17 @@ Now we need to tell the blog app where to find the `hello-world` dependency.
We do this by adding a package repository specification to the blog's
`composer.json`:

```json
{
"name": "acme/blog",
"repositories": {
"acme/hello-world": {
"vcs": { "url": "https://github.com/composer/hello-world" }
{
"name": "acme/blog",
"repositories": {
"acme/hello-world": {
"vcs": { "url": "https://github.com/composer/hello-world" }
}
},
"require": {
"acme/hello-world": "dev-master"
}
},
"require": {
"acme/hello-world": "dev-master"
}
}
```

For more details on how package repositories work and what other types are
available, see [Repositories].
Expand Down
Loading

0 comments on commit 605fae4

Please sign in to comment.