03.12.2015 Views

laravel4cookbook

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Deployment 110<br />

68 InputArgument::REQUIRED,<br />

69 "Destination host."<br />

70 ]<br />

71 ];<br />

72 }<br />

73<br />

74 protected function getOptions()<br />

75 {<br />

76 return [<br />

77 [<br />

78 "target",<br />

79 null,<br />

80 InputOption::VALUE_OPTIONAL,<br />

81 "Distribution path.",<br />

82 null<br />

83 ]<br />

84 ];<br />

85 }<br />

86 }<br />

.<br />

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

The DistributeCommand class accepts a host (remote server name) argument and a –target option.<br />

Like the copy and clean commands; the –target option will override the default ../distribute folder<br />

with one of your choosing.<br />

The host argument needs to match a key in your app/config/host.php configuration file. It carefully<br />

constructs and escapes a shell command instruction rsync to synchronise files from the distribution<br />

folder to a path on the remote server.<br />

Once the files have been synchronised, it will inspect the messy output of the rsync command and<br />

return number number of bytes and files transferred.<br />

.<br />

The intricacies of SSH and Rsync are outside the scope of this tutorial. You can learn more about<br />

Rsync at: https://calomel.org/rsync_tips.html<br />

You can watch the progress of an upload (to the remote server) by connecting via SSH, navigating<br />

to the folder and running the command: du -hs

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

Saved successfully!

Ooh no, something went wrong!