Skip to content

Instantly share code, notes, and snippets.

View coreymcmahon's full-sized avatar

Corey McMahon coreymcmahon

View GitHub Profile
@coreymcmahon
coreymcmahon / UsersController.php
Created March 25, 2014 03:03
Using the custom response facade - www.slashnode.com
<?php namespace Acme\Controllers;
use Acme\Repositories\UserRepositoryInterface as UserRepository;
class UsersController extends \BaseController
{
protected $userRepository;
public function __construct(UserRepository $userRepository)
{
@coreymcmahon
coreymcmahon / start.php
Created May 22, 2014 06:20
Documented approach for defining environments in Laravel - http://www.slashnode.com
<?php
// ... etc
// in bootstrap/start.php
$env = $app->detectEnvironment(array(
'local' => array('localhost'),
'staging' => array('staging.domain.org'),
'production' => array('domain.org'),
));
@coreymcmahon
coreymcmahon / start.php
Created May 22, 2014 06:27
Using a config file to define the environment name in Laravel - http://www.slashnode.com
<?php
// ... etc
// in bootstrap/start.php
$env = $app->detectEnvironment(function ()
{
return require __DIR__.'/environment.php';
});
@coreymcmahon
coreymcmahon / start.php
Created May 22, 2014 06:31
Setting the environment name in Laravel using an environment variable - http://www.slashnode.com
<?php
// ... etc
// in bootstrap/start.php
$env = $app->detectEnvironment(function ()
{
return getenv('APP_ENV');
});
@coreymcmahon
coreymcmahon / Config.php
Created July 12, 2014 08:13
Mocking the Filesystem during BDD with Behat and PHPSpec - www.slashnode.com
<?php
class Config
{
protected $settings;
public function __construct($settings = array())
{
$this->settings = $settings;
}
@coreymcmahon
coreymcmahon / ConfigSpec.php
Created July 12, 2014 08:15
Mocking the Filesystem during BDD with Behat and PHPSpec - www.slashnode.com
<?php
namespace spec;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class ConfigSpec extends ObjectBehavior
{
function it_is_initializable()
@coreymcmahon
coreymcmahon / FeatureContext.php
Created July 12, 2014 08:16
Mocking the Filesystem during BDD with Behat and PHPSpec - www.slashnode.com
<?php
use Behat\Behat\Tester\Exception\PendingException;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use org\bovigo\vfs\vfsStream;
/**
@coreymcmahon
coreymcmahon / config.feature
Created July 12, 2014 08:17
Mocking the Filesystem during BDD with Behat and PHPSpec - www.slashnode.com
Feature: Configuration Files
In order to configure my application
As a developer
I need to be able to store configuration options in a file
Scenario: Getting a configured option
Given there is a configuration file
And the option 'timezone' is configured to 'UTC'
When I load the configuration file
Then I should get 'UTC' as 'timezone' option
@coreymcmahon
coreymcmahon / FeatureContext.php
Created July 12, 2014 08:32
Mocking the Filesystem during BDD with Behat and PHPSpec - www.slashnode.com
<?php
/** ... etc ... */
class FeatureContext implements SnippetAcceptingContext
{
protected $filesystem;
protected $config;
protected $sut;
@coreymcmahon
coreymcmahon / ServiceLayerExample.php
Created July 18, 2014 04:57
Example of using a service layer w/ the repository pattern - www.slashnode.com
<?php
/* UserRepository.php */
namespace Acme\Repositories;
class UserRepository extends AbstractRepository implements UserRepositoryInterface
{
// etc...
}