Skip to content

Commit 7477584

Browse files
committed
Initial Commit
Signed-off-by: Tom Shafer <[email protected]>
0 parents  commit 7477584

20 files changed

+1449
-0
lines changed

.gitattributes

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/tests export-ignore
2+
.gitattributes export-ignore
3+
.gitignore export-ignore
4+
.scrutinizer.yml export-ignore
5+
.travis.yml export-ignore
6+
phpunit.php export-ignore
7+
phpunit.xml export-ignore

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/vendor
2+
composer.phar
3+
composer.lock
4+
.DS_Store
5+
Thumbs.db
6+
.idea

.scrutinizer.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
filter:
2+
excluded_paths: [tests/*]
3+
4+
checks:
5+
php:
6+
code_rating: true
7+
duplication: true
8+
variable_existence: true
9+
useless_calls: true
10+
use_statement_alias_conflict: true
11+
unused_variables: true
12+
unused_properties: true
13+
unused_parameters: true
14+
unused_methods: true
15+
unreachable_code: true
16+
sql_injection_vulnerabilities: true
17+
security_vulnerabilities: true
18+
precedence_mistakes: true
19+
precedence_in_conditions: true
20+
parameter_non_unique: true
21+
no_property_on_interface: true
22+
no_non_implemented_abstract_methods: true
23+
deprecated_code_usage: true
24+
closure_use_not_conflicting: true
25+
closure_use_modifiable: true
26+
avoid_useless_overridden_methods: true
27+
avoid_conflicting_incrementers: true
28+
assignment_of_null_return: true
29+
avoid_usage_of_logical_operators: true
30+
ensure_lower_case_builtin_functions: true
31+
foreach_traversable: true
32+
function_in_camel_caps: true
33+
instanceof_class_exists: true
34+
lowercase_basic_constants: true
35+
lowercase_php_keywords: true
36+
missing_arguments: true
37+
no_commented_out_code: true
38+
no_duplicate_arguments: true
39+
no_else_if_statements: true
40+
no_space_between_concatenation_operator: true
41+
no_space_inside_cast_operator: true
42+
no_trailing_whitespace: true
43+
no_underscore_prefix_in_properties: true
44+
no_unnecessary_if: true
45+
no_unnecessary_function_call_in_for_loop: true
46+
non_commented_empty_catch_block: true
47+
php5_style_constructor: true
48+
parameters_in_camelcaps: true
49+
prefer_while_loop_over_for_loop: true
50+
properties_in_camelcaps: true
51+
require_scope_for_methods: true
52+
require_scope_for_properties: true
53+
spacing_around_conditional_operators: true
54+
spacing_around_non_conditional_operators: true
55+
spacing_of_function_arguments: true

.travis.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
language: php
2+
3+
php:
4+
- 5.4
5+
- 5.5
6+
- 5.6
7+
- hhvm
8+
9+
sudo: false
10+
11+
install: travis_retry composer install --no-interaction --prefer-source
12+
13+
script: vendor/bin/phpunit

CONTRIBUTING.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Laravel Contribution Guide
2+
3+
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](http://laravel.com/docs/contributions). Please review the entire guide before sending a pull request.

composer.json

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "laravelcollective/remote",
3+
"description": "Remote for The Laravel Framework.",
4+
"keywords": [
5+
"framework",
6+
"laravel",
7+
"remote"
8+
],
9+
"license": "MIT",
10+
"authors": [
11+
{
12+
"name": "Taylor Otwell",
13+
"email": "[email protected]"
14+
}
15+
],
16+
"require": {
17+
"php": ">=5.4.0",
18+
"illuminate/support": "~5.0",
19+
"illuminate/filesystem": "~5.0",
20+
"phpseclib/phpseclib": "0.3.*"
21+
},
22+
"require-dev": {
23+
"illuminate/console": "~5.0",
24+
"mockery/mockery": "~0.9",
25+
"phpunit/phpunit": "~4.0"
26+
},
27+
"autoload": {
28+
"psr-4": {
29+
"Collective\\Remote\\": "src/"
30+
}
31+
}
32+
}

config/remote.php

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
return [
3+
/*
4+
|--------------------------------------------------------------------------
5+
| Default Remote Connection Name
6+
|--------------------------------------------------------------------------
7+
|
8+
| Here you may specify the default connection that will be used for SSH
9+
| operations. This name should correspond to a connection name below
10+
| in the server list. Each connection will be manually accessible.
11+
|
12+
*/
13+
'default' => 'production',
14+
/*
15+
|--------------------------------------------------------------------------
16+
| Remote Server Connections
17+
|--------------------------------------------------------------------------
18+
|
19+
| These are the servers that will be accessible via the SSH task runner
20+
| facilities of Laravel. This feature radically simplifies executing
21+
| tasks on your servers, such as deploying out these applications.
22+
|
23+
*/
24+
'connections' => [
25+
'production' => [
26+
'host' => '',
27+
'username' => '',
28+
'password' => '',
29+
'key' => '',
30+
'keyphrase' => '',
31+
'root' => '/var/www',
32+
],
33+
],
34+
/*
35+
|--------------------------------------------------------------------------
36+
| Remote Server Groups
37+
|--------------------------------------------------------------------------
38+
|
39+
| Here you may list connections under a single group name, which allows
40+
| you to easily access all of the servers at once using a short name
41+
| that is extremely easy to remember, such as "web" or "database".
42+
|
43+
*/
44+
'groups' => [
45+
'web' => [ 'production' ]
46+
],
47+
];

license.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) <LaravelCollective>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

phpunit.php

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/*
3+
|--------------------------------------------------------------------------
4+
| Register The Composer Auto Loader
5+
|--------------------------------------------------------------------------
6+
|
7+
| Composer provides a convenient, automatically generated class loader
8+
| for our application. We just need to utilize it! We'll require it
9+
| into the script here so that we do not have to worry about the
10+
| loading of any our classes "manually". Feels great to relax.
11+
|
12+
*/
13+
require __DIR__.'/vendor/autoload.php';
14+
/*
15+
|--------------------------------------------------------------------------
16+
| Set The Default Timezone
17+
|--------------------------------------------------------------------------
18+
|
19+
| Here we will set the default timezone for PHP. PHP is notoriously mean
20+
| if the timezone is not explicitly set. This will be used by each of
21+
| the PHP date and date-time functions throughout the application.
22+
|
23+
*/
24+
date_default_timezone_set('UTC');

phpunit.xml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
bootstrap="phpunit.php"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnError="false"
11+
stopOnFailure="false"
12+
syntaxCheck="true"
13+
strict="false"
14+
verbose="true"
15+
>
16+
<testsuites>
17+
<testsuite name="Laravel Remote Test Suite">
18+
<directory suffix="Test.php">./tests</directory>
19+
</testsuite>
20+
</testsuites>
21+
<filter>
22+
<whitelist processUncoveredFilesFromWhitelist="true">
23+
<directory suffix=".php">./src</directory>
24+
</whitelist>
25+
</filter>
26+
</phpunit>

readme.md

+134
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# SSH
2+
3+
[![Build Status](https://travis-ci.org/tshafer/remote.svg?branch=master)](https://travis-ci.org/tshafer/remote)
4+
[![Total Downloads](https://poser.pugx.org/LaravelCollective/html/downloads.svg)](https://packagist.org/packages/laravelcollective/html)
5+
[![Latest Stable Version](https://poser.pugx.org/LaravelCollective/html/v/stable.svg)](https://packagist.org/packages/laravelcollective/html)
6+
[![Latest Unstable Version](https://poser.pugx.org/LaravelCollective/html/v/unstable.svg)](https://packagist.org/packages/laravelcollective/html)
7+
[![License](https://poser.pugx.org/LaravelCollective/html/license.svg)](https://packagist.org/packages/laravelcollective/html)
8+
9+
- [Installation](#installation)
10+
- [Configuration](#configuration)
11+
- [Basic Usage](#basic-usage)
12+
- [Tasks](#tasks)
13+
- [SFTP Downloads](#sftp-downloads)
14+
- [SFTP Uploads](#sftp-uploads)
15+
- [Tailing Remote Logs](#tailing-remote-logs)
16+
17+
<a name="installation"></a>
18+
## Installation
19+
20+
> If you have changed the top-level namespace to something like 'MyCompany', then you would use the new namespace instead of 'App'.
21+
22+
Begin by installing this package through Composer. Edit your project's `composer.json` file to require `laravelcollective/remote`.
23+
24+
"require": {
25+
"laravelcollective/remote": "~5.0"
26+
}
27+
28+
Next, update Composer from the Terminal:
29+
30+
composer update
31+
32+
Next, add your new provider to the `providers` array of `config/app.php`:
33+
34+
```php
35+
'providers' => [
36+
// ...
37+
'Collective\Remote\RemoteServiceProvider',
38+
// ...
39+
],
40+
```
41+
42+
Finally, add two class aliases to the `aliases` array of `config/app.php`:
43+
44+
```php
45+
'aliases' => [
46+
// ...
47+
'SSH' => 'Collective\Remote\RemoteFacade',
48+
// ...
49+
],
50+
```
51+
<a name="configuration"></a>
52+
## Configuration
53+
54+
Laravel includes a simple way to SSH into remote servers and run commands, allowing you to easily build Artisan tasks that work on remote servers. The `SSH` facade provides the access point to connecting to your remote servers and running commands.
55+
56+
The configuration file is located at `config/remote.php`, and contains all of the options you need to configure your remote connections. The `connections` array contains a list of your servers keyed by name. Simply populate the credentials in the `connections` array and you will be ready to start running remote tasks. Note that the `SSH` can authenticate using either a password or an SSH key.
57+
58+
> **Note:** Need to easily run a variety of tasks on your remote server? Check out the [Envoy task runner](http://laravel.com/docs/5.0/envoy)!
59+
60+
<a name="basic-usage"></a>
61+
## Basic Usage
62+
63+
#### Running Commands On The Default Server
64+
65+
To run commands on your `default` remote connection, use the `SSH::run` method:
66+
67+
SSH::run([
68+
'cd /var/www',
69+
'git pull origin master',
70+
]);
71+
72+
#### Running Commands On A Specific Connection
73+
74+
Alternatively, you may run commands on a specific connection using the `into` method:
75+
76+
SSH::into('staging')->run([
77+
'cd /var/www',
78+
'git pull origin master',
79+
]);
80+
81+
#### Catching Output From Commands
82+
83+
You may catch the "live" output of your remote commands by passing a Closure into the `run` method:
84+
85+
SSH::run($commands, function($line)
86+
{
87+
echo $line.PHP_EOL;
88+
});
89+
90+
## Tasks
91+
<a name="tasks"></a>
92+
93+
If you need to define a group of commands that should always be run together, you may use the `define` method to define a `task`:
94+
95+
SSH::into('staging')->define('deploy', [
96+
'cd /var/www',
97+
'git pull origin master',
98+
'php artisan migrate',
99+
]);
100+
101+
Once the task has been defined, you may use the `task` method to run it:
102+
103+
SSH::into('staging')->task('deploy', function($line)
104+
{
105+
echo $line.PHP_EOL;
106+
});
107+
108+
<a name="sftp-downloads"></a>
109+
## SFTP Downloads
110+
111+
The `SSH` class includes a simple way to download files using the `get` and `getString` methods:
112+
113+
SSH::into('staging')->get($remotePath, $localPath);
114+
115+
$contents = SSH::into('staging')->getString($remotePath);
116+
117+
<a name="sftp-uploads"></a>
118+
## SFTP Uploads
119+
120+
The `SSH` class also includes a simple way to upload files, or even strings, to the server using the `put` and `putString` methods:
121+
122+
SSH::into('staging')->put($localFile, $remotePath);
123+
124+
SSH::into('staging')->putString($remotePath, 'Foo');
125+
126+
<a name="tailing-remote-logs"></a>
127+
## Tailing Remote Logs
128+
129+
Laravel includes a helpful command for tailing the `laravel.log` files on any of your remote connections. Simply use the `tail` Artisan command and specify the name of the remote connection you would like to tail:
130+
131+
php artisan tail staging
132+
133+
php artisan tail staging --path=/path/to/log.file
134+

0 commit comments

Comments
 (0)