From 358645ef622676ee6cac177b0b8a01f874df8c9f Mon Sep 17 00:00:00 2001 From: Vincent Klaiber Date: Wed, 12 Nov 2014 14:56:09 +0100 Subject: [PATCH] Update PHP snippets indent. --- README.md | 120 +++++++++++++++++++++++++++--------------------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index faa0dd5..46d6127 100644 --- a/README.md +++ b/README.md @@ -8,35 +8,35 @@ Use hashids when you do not want to expose your database ids to the user. ## Installation Begin by installing the package through Composer. Edit your project's `composer.json` file to require `mitch/hashids`. - ```php - "require": { +```php +"require": { "mitch/hashids": "1.x" - } - ``` +} +``` Next use Composer to update your project from the the Terminal: - ```php - php composer.phar update - ``` +```php +php composer.phar update +``` Once the package has been installed you'll need to add the service provider. Open your `app/config/app.php` configuration file, and add a new item to the `providers` array. - ```php - 'Mitch\Hashids\HashidsServiceProvider' - ``` +```php +'Mitch\Hashids\HashidsServiceProvider' +``` After doing this you also need to add an alias. In your `app/config/app.php` file, add this to the `aliases` array. - ```php - 'Hashids' => 'Mitch\Hashids\Hashids' - ``` +```php +'Hashids' => 'Mitch\Hashids\Hashids' +``` Now last but not least you need to publish to package configuration from your Terminal: - ```php - php artisan config:publish mitch/hashids - ``` +```php +php artisan config:publish mitch/hashids +``` ## Usage Once you've followed all the steps and completed the installation you can use Hashids. @@ -44,69 +44,69 @@ Once you've followed all the steps and completed the installation you can use Ha ### Encoding You can simply encrypt on id: - ```php - Hashids::encode(1); // Creating hash... Ri7Bi - ``` +```php +Hashids::encode(1); // Creating hash... Ri7Bi +``` -or multiple.. +or multiple... - ```php - Hashids::encode(1, 21, 12, 12, 666); // Creating hash... MMtaUpSGhdA - ``` +```php +Hashids::encode(1, 21, 12, 12, 666); // Creating hash... MMtaUpSGhdA +``` ### Decoding It's the same thing but the other way around: - ```php - Hashids::decode('Ri7Bi'); +```php +Hashids::decode('Ri7Bi'); - // Returns - array (size=1) - 0 => int 1 - ``` +// Returns +array (size=1) + 0 => int 1 +``` -or multiple.. +or multiple... - ```php - Hashids::decode('MMtaUpSGhdA'); +```php +Hashids::decode('MMtaUpSGhdA'); - // Returns - array (size=5) - 0 => int 1 - 1 => int 21 - 2 => int 12 - 3 => int 12 - 4 => int 666 - ``` +// Returns +array (size=5) + 0 => int 1 + 1 => int 21 + 2 => int 12 + 3 => int 12 + 4 => int 666 +``` ### Injecting Hashids Now it's also possible to have Hashids injected into your class. Lets look at this controller as an example.. - ```php - class ExampleController extends BaseController - { - protected $hashids; - - public function __construct(Hashids\Hashids $hashids) - { - $this->hashids = $hashids; - } - - public function getIndex() - { - $hash = $this->hashids->encode(1); - return View::make('example.index', compact('hash')); - } - } - ``` +```php +class ExampleController extends BaseController +{ + protected $hashids; + + public function __construct(Hashids\Hashids $hashids) + { + $this->hashids = $hashids; + } + + public function getIndex() + { + $hash = $this->hashids->encode(1); + return View::make('example.index', compact('hash')); + } +} +``` The original classname and namespace has been bound in the IoC container to return our instantiated Hashids class. ### Using IoC Create a Hashids instance with the IoC - ```php - App::make('Hashids\Hashids')->encode(1); - ``` +```php +App::make('Hashids\Hashids')->encode(1); +``` ## That's it! Documentation about [Hashids can be found here](https://github.com/ivanakimov/hashids.php).