03.12.2015 Views

laravel4cookbook

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Deployment 100<br />

78 else if (ends_with($output, ".min.js"))<br />

79 {<br />

80 $options["type"] = "js";<br />

81 $this->call("asset:minify", $options);<br />

82 }<br />

83 else<br />

84 {<br />

85 $this->call("asset:combine", $options);<br />

86 }<br />

87 }<br />

88<br />

89 protected function getArguments()<br />

90 {<br />

91 return [];<br />

92 }<br />

93<br />

94 protected function getOptions()<br />

95 {<br />

96 return [];<br />

97 }<br />

98<br />

99 protected function getPath()<br />

100 {<br />

101 return public_path();<br />

102 }<br />

103 }<br />

.<br />

This file should be saved as app/commands/WatchCommand.php.<br />

The WatchCommand class is a step up from the BuildCommand class in that it processes asset files<br />

similarly. Where it excels is in how it is able to watch the individual files in app/config/*/asset.php.<br />

When a Watcher targets a specific file (with the $watcher->watch() method); it generates a<br />

Listener. Listeners can have events bound to them (as is the case with the onModify() event listener<br />

method).<br />

When these files change, the processed asset files they form part of are rebuilt, using the same logic<br />

as in the build command.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!