• Complain

it-ebooks - laravel 源码解析

Here you can read online it-ebooks - laravel 源码解析 full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2018, publisher: iBooker it-ebooks, genre: Humor. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

it-ebooks laravel 源码解析
  • Book:
    laravel 源码解析
  • Author:
  • Publisher:
    iBooker it-ebooks
  • Genre:
  • Year:
    2018
  • Rating:
    3 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 60
    • 1
    • 2
    • 3
    • 4
    • 5

laravel 源码解析: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "laravel 源码解析" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

it-ebooks: author's other books


Who wrote laravel 源码解析? Find out the surname, the name of the author of the book and a list of all author's works by series.

laravel 源码解析 — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "laravel 源码解析" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Laravel Broadcast
Laravel Broadcast

webWebSocketsWebSocketWebSocket

laravellaravelwebSocket.IOjsLaravel EchoSocket.IOlaravelSocket.IO

laravelredispusherredisSocket.IOnodejstlaverdure/laravel-echo-serverpusherSocket.IO

redislaravel-echo-servernodejsSocket.IO

IocBroadcastManager:

class BroadcastServiceProvider extends ServiceProvider { public function register () { $this->app->singleton(BroadcastManager::class, function ($app) { return new BroadcastManager($app); }); $this->app->singleton(BroadcasterContract::class, function ($app) { return $app->make(BroadcastManager::class)->connection(); }); $this->app->alias( BroadcastManager::class, BroadcastingFactory::class ); }}

BroadcastManagerBroadcastServiceProvider

public function connection ($driver = null) { return $this->driver($driver);} public function driver ($name = null) { $name = $name ?: $this->getDefaultDriver(); return $this->drivers[$name] = $this->get($name);} protected function get ($name) { return isset ($this->drivers[$name]) ? $this->drivers[$name] : $this->resolve($name);} protected function resolve ($name) { $config = $this->getConfig($name); if (is_null($config)) { throw new InvalidArgumentException( "Broadcaster [{$name}] is not defined." ); } if ( isset ($this->customCreators[$config[ 'driver' ]])) { return $this->callCustomCreator($config); } $driverMethod = 'create' .ucfirst($config[ 'driver' ]). 'Driver' ; if (! method_exists($this, $driverMethod)) { throw new InvalidArgumentException( "Driver [{$config['driver']}] is not supported." ); } return $this->{$driverMethod}($config);} protected function createRedisDriver (array $config) { return new RedisBroadcaster( $this->app->make( 'redis' ), Arr::get($config, 'connection' ) );}

LaravelIlluminate\Contracts\Broadcasting\ShouldBroadcast

ShouldBroadcastbroadcastOn. broadcastOnChannelPrivateChannelPresenceChannelChannelPrivateChannelsPresenceChannels

class ServerCreated implements ShouldBroadcast { use SerializesModels ; public $user; // queue.php broadcastQueue public $broadcastQueue = 'your-queue-name' ; public function __construct (User $user) { $this->user = $user; } public function broadcastOn () { return new PrivateChannel( 'user.' .$this->user->id); } //Laravel public function broadcastAs () { return 'server.created' ; } //: public function broadcastWith () { return [ 'id' => $this->user->id]; } // true : public function broadcastWhen () { return $this->value > ; }}

publicJavaScript$userElouqent

{ "user" : { "id" : , "name" : "Patrick Stewart" ... }}

event

public function dispatch ($event, $payload = [], $halt = false) { list ($event, $payload) = $this->parseEventAndPayload( $event, $payload ); if ($this->shouldBroadcast($payload)) { $this->broadcastEvent($payload[]); } ... } protected function shouldBroadcast (array $payload) { return isset ($payload[]) && $payload[] instanceof ShouldBroadcast; } protected function broadcastEvent ($event) { $this->container->make(BroadcastFactory::class)->queue($event); }

BroadcastManagerquene

public function queue ($event) { $connection = $event instanceof ShouldBroadcastNow ? 'sync' : null ; if (is_null($connection) && isset ($event->connection)) { $connection = $event->connection; } $queue = null ; if ( isset ($event->broadcastQueue)) { $queue = $event->broadcastQueue; } elseif ( isset ($event->queue)) { $queue = $event->queue; } $this->app->make( 'queue' )->connection($connection)->pushOn( $queue, new BroadcastEvent( clone $event) );}

quene

class BroadcastEvent implements ShouldQueue { public function handle (Broadcaster $broadcaster) { $name = method_exists($this->event, 'broadcastAs' ) ? $this->event->broadcastAs() : get_class($this->event); $broadcaster->broadcast( array_wrap($this->event->broadcastOn()), $name, $this->getPayloadFromEvent($this->event) ); } protected function getPayloadFromEvent ($event) { if (method_exists($event, 'broadcastWith' )) { return array_merge( $event->broadcastWith(), [ 'socket' => data_get($event, 'socket' )] ); } $payload = []; foreach (( new ReflectionClass($event))->getProperties(ReflectionProperty::IS_PUBLIC) as $property) { $payload[$property->getName()] = $this->formatProperty($property->getValue($event)); } return $payload; } protected function formatProperty ($value) { if ($value instanceof Arrayable) { return $value->toArray(); } return $value; }}

broadcasterbroadcastredis

class RedisBroadcaster extends Broadcaster { public function broadcast (array $channels, $event, array $payload = []) { $connection = $this->redis->connection($this->connection); $payload = json_encode([ 'event' => $event, 'data' => $payload, 'socket' => Arr::pull($payload, 'socket' ), ]); foreach ($this->formatChannels($channels) as $channel) { $connection->publish($channel, $payload); } }} protected function formatChannels (array $channels) { return array_map( function ($channel) { return (string) $channel; }, $channels);}

broadcastredispublishredis

LaravelHTTPLaravel EchoHTTP

Laravel

Broadcast::routes();

Broadcast::routesweb

Broadcast::routes($attributes);

routes/channels.phpBroadcast::channel

Broadcast::channel( 'order.{orderId}' , function ($user, $orderId) { return $user->id === Order::findOrNew($orderId)->user_id;});

channeltruefalse

{orderId} ID

HTTPorder IDOrder :

Broadcast::channel( 'order.{order}' , function ($user, Order $order) { return $user->id === $order->user_id;});
class BroadcastManager implements FactoryContract { public function routes (array $attributes = null) { if ($this->app->routesAreCached()) { return ; } $attributes = $attributes ?: [ 'middleware' => [ 'web' ]]; $this->app[ 'router' ]->group($attributes, function ($router) { $router->post( '/broadcasting/auth' , BroadcastController::class. '@authenticate' ); }); }}

Controller

class BroadcastController extends Controller { public function authenticate (Request $request) { return Broadcast::auth($request); }}

Socket Iojavascriptcontroller

public function auth ($request) { if (Str::startsWith($request->channel_name, [ 'private-' , 'presence-' ]) && ! $request->user()) { throw new HttpException(); } $channelName = Str::startsWith($request->channel_name, 'private-' ) ? Str::replaceFirst( 'private-' , '' , $request->channel_name) : Str::replaceFirst( 'presence-' , '' , $request->channel_name); return parent ::verifyUserCanAccessChannel( $request, $channelName );}
Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «laravel 源码解析»

Look at similar books to laravel 源码解析. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «laravel 源码解析»

Discussion, reviews of the book laravel 源码解析 and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.