Upload
theavuth-nhel
View
170
Download
2
Embed Size (px)
Citation preview
@PhillSparks
• API Engineer at CrowdLab
• From Leicester, UK
• Climbing Instructor
•Scout
• Laravel Core Team
Laravel
• With Laravel since 1.5.9
• Core Team Member
• Past: Quality Team
• Now: Community engagement and support
Laravel
• With Laravel since 1.5.9
• Core Team Member
• Past: Quality Team
• Now: Community engagement and support
• Dayle still owes me 9000 support points!
Software Design PatternsEach pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice.
-- Christopher Alexander, AIS+77
“ ”
The Patterns
• Builder
• Chain of Responsibility
• Command
• Facade
• Factory
• Iterator
• Mediator
• Observer
• Presenter
• Repository
• Singleton
• Strategy
Interfaces
namespace Illuminate\Auth;
interface UserInterface {
public function getAuthIdentifier();
public function getAuthPassword();
}
class GenericUser implements UserInterface {
• 244 interfaces in Laravel (including vendors)
• 25 from Laravel Core
• 65 from Symfony
• 73 from Swiftmailer
Interface
Abstract Classes
namespace Illuminate\Database\Eloquent\Relations;
abstract class Relation {
abstract public function addConstraints();
abstract public function getResults();
}
class BelongsTo extends Relation {
Abstract Classes
• 128 abstract classes in Laravel (including vendors)
• 14 from Laravel Core
• 15 from Swiftmailer
• 40 from Symfony
Dispatchernamespace Illuminate\Events;
class LoginHandler {
function handle($user) {
// do something with $data
}
}
Event::listen(‘user.login’, ‘LoginHandler’);
Event::fire(‘user.login’, $user);
Builder (aka Manager)
• Examples:
• Illuminate\Auth\AuthManager
• Illuminate\Cache\CacheManager
• Illuminate\Queue\QueueManager
• Illuminate\Session\SessionManager
Factory
• Examples:
• Illuminate\Database\DatabaseManager
• Illuminate\Database\Connectors\ ConnectionFactory
• Illuminate\Validation\Factory
Service Provider
• Core to Laravel’s IoC
• See Illuminate\Support\ServiceProvider
• Examples:
• Illuminate\Auth\AuthServiceProvider
• Illuminate\Hash\HashServiceProvider
• Illuminate\Log\LogServiceProvider
Strategy
• Examples:
• Illuminate\Cache\StoreInterface
• Illuminate\Config\LoaderInterface
• Illuminate\Database - Builders & Grammars
• Illuminate\Translation\LoaderInterface
• Illuminate\View\ViewFinderInterface