Skip to content
This repository was archived by the owner on Oct 26, 2025. It is now read-only.

Commit 7205255

Browse files
authored
Merge pull request #1 from Sammyjo20/feature/framework
Feature | Turn into a framework
2 parents 689dd9d + 9256759 commit 7205255

24 files changed

Lines changed: 465 additions & 161 deletions

.docker/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2

.gitattributes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/.github export-ignore
2+
/tests export-ignore
3+
.editorconfig export-ignore
4+
.gitattributes export-ignore
5+
.gitignore export-ignore
6+
phpunit.xml export-ignore
7+
.php-cs-fixer.dist.php export-ignore
8+
phpstan.baseline.neon export-ignore
9+
phpstan.dist.neon export-ignore

.github/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<div align="center">
2+
3+
# 🤫 _`SSH PHP` !_
4+
5+
### The ridiculously simple framework for building PHP SSH apps! 🔥
6+
7+
<img width="974" alt="Screenshot 2024-07-26 at 18 09 49" src="https://github.com/user-attachments/assets/cdecc8fb-ba0f-4c0d-8aff-9e43f539f3f3">
8+
9+
</div>
10+
11+
> This project is in early access, and I'm quite new to Docker so please consider contributing if you think this could be improved! Please share your thoughts in the issues/discussions. Thank you!
12+
13+
# What the shell?!
14+
15+
I know right! I've just ran `ssh localhost` and I've got a full PHP application running in my terminal?! What! Me too. When I first saw [Joe Tannenbaum's](https://joe.codes/) Tweet where he showed off his awesome `ssh cli.lab.joe.codes` I thought to myself, I had to get this working myself. I have a secret project that I'm currently working on but during my research I managed to adapt his guide for getting [charmbracelet/wish](https://github.com/charmbracelet/wish) running with PHP to work with Docker!
16+
17+
# Why?
18+
This is mainly for building [TUIs](https://en.wikipedia.org/wiki/Text-based_user_interface) however it can run any PHP script so you can build cool forms, resumes or anything you desire!
19+
20+
# Why Docker?
21+
22+
Well, messing around with SSH is not really something I want to do to my servers. Additionally, if I'm going to have the public **SSH into my server** I'm going to want to make sure it's ring-fenced. With a Docker container, it's even more ring-fenced then just SSHing directly into the server.
23+
24+
# Installation
25+
To get started, run the following Composer installation command
26+
27+
```
28+
composer create-project sammyjo20/ssh-php ssh-app-name
29+
```
30+
31+
# Deploying to production
32+
33+
### Credits
34+
35+
- Huge thanks to [Joe Tannenbaum's](https://joe.codes/) for his awesome [blog post](https://blog.joe.codes/creating-ssh-apps-with-charm-wish-and-laravel-prompts) and his support via Twitter/X DMs!

.github/workflows/php-cs-fixer.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Code Style
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
pull_request:
8+
branches:
9+
- '*'
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
php-cs-fixer:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v3
21+
- name: Run PHP CS Fixer
22+
uses: docker://oskarstark/php-cs-fixer-ga
23+
with:
24+
args: --config=.php-cs-fixer.dist.php --allow-risky=yes
25+
- name: Commit changes
26+
uses: stefanzweifel/git-auto-commit-action@v4
27+
with:
28+
commit_message: 🪄 Code Style Fixes

.github/workflows/phpstan.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: PHPStan
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
pull_request:
8+
branches:
9+
- '*'
10+
11+
jobs:
12+
phpstan:
13+
name: phpstan
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
18+
- name: Setup PHP
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: '8.3'
22+
coverage: none
23+
24+
- name: Install composer dependencies
25+
uses: ramsey/composer-install@v2
26+
27+
- name: Run PHPStan
28+
run: ./vendor/bin/phpstan analyse --error-format=github

.github/workflows/tests.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
pull_request:
8+
branches:
9+
- '*'
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
tests:
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
fail-fast: true
19+
matrix:
20+
os: [ ubuntu-latest ]
21+
php: [ 8.3 ]
22+
stability: [ prefer-lowest, prefer-stable ]
23+
24+
name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }}
25+
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v3
29+
30+
- name: Setup PHP
31+
uses: shivammathur/setup-php@v2
32+
with:
33+
php-version: ${{ matrix.php }}
34+
# extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
35+
coverage: none
36+
37+
- name: Setup problem matchers
38+
run: |
39+
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
40+
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
41+
42+
- name: Install dependencies
43+
run: |
44+
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
45+
- name: Execute tests
46+
run: ./vendor/bin/pest

.gitignore

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,14 @@
77
/.idea
88
/.vscode
99

10-
# SSH Config
11-
data/.ssh
10+
# Project dependencies
11+
/vendor
12+
/composer.lock
13+
14+
# Caches, externally stored stuff, etc
15+
.php-cs-fixer.cache
16+
.phpunit.result.cache
17+
tests/Fixtures/Saloon
18+
19+
# environments/configs
20+
phpstan.neon

.php-cs-fixer.dist.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
$finder = Symfony\Component\Finder\Finder::create()
4+
->in([
5+
__DIR__,
6+
])
7+
->name('*.php')
8+
->notName('*.blade.php')
9+
->ignoreDotFiles(true)
10+
->ignoreVCS(true)
11+
->exclude(['vendor', 'node_modules']);
12+
13+
$config = new PhpCsFixer\Config();
14+
15+
// Rules from: https://cs.symfony.com/doc/rules/index.html
16+
17+
return $config->setRules([
18+
'@PSR2' => true,
19+
'array_syntax' => ['syntax' => 'short'],
20+
'ordered_imports' => ['sort_algorithm' => 'length'],
21+
'no_unused_imports' => true,
22+
'not_operator_with_successor_space' => true,
23+
'trailing_comma_in_multiline' => true,
24+
'single_quote' => ['strings_containing_single_quote_chars' => true],
25+
'phpdoc_scalar' => true,
26+
'unary_operator_spaces' => true,
27+
'binary_operator_spaces' => true,
28+
'blank_line_before_statement' => [
29+
'statements' => ['declare', 'return', 'throw', 'try'],
30+
],
31+
'phpdoc_single_line_var_spacing' => true,
32+
'phpdoc_var_without_name' => true,
33+
'method_argument_space' => [
34+
'on_multiline' => 'ensure_fully_multiline',
35+
'keep_multiple_spaces_after_comma' => true,
36+
],
37+
'return_type_declaration' => [
38+
'space_before' => 'none'
39+
],
40+
'declare_strict_types' => true,
41+
'blank_line_after_opening_tag' => true,
42+
'single_import_per_statement' => true,
43+
'mb_str_functions' => true,
44+
'no_superfluous_phpdoc_tags' => true,
45+
'no_blank_lines_after_phpdoc' => true,
46+
'no_empty_phpdoc' => true,
47+
'phpdoc_trim' => true,
48+
])->setFinder($finder);

Dockerfile

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,19 @@
1-
FROM ubuntu:24.04
1+
FROM sammyjo20/ssh-php:latest
22

3-
# Install Go
3+
# Install Composer
44

5-
RUN apt update && apt install golang git php php-cli sudo -y
5+
RUN apt update && apt install composer -y
66

7-
RUN export PATH=$PATH:/usr/local/bin/go
7+
# Copy all files
88

9-
# Copy our very basic script
9+
COPY ./src /app/php/src
10+
COPY ./composer.json /app/php
11+
COPY ./composer.lock /app/php
1012

11-
COPY ./src/go/main.go .
13+
# Create a symbolic link
1214

13-
RUN go mod init sammyjo20/jourminal
15+
RUN ln -s /app/php/src/index.php /app/php/index.php
1416

15-
# Install Dependencies
17+
# Run Composer install without dependencies
1618

17-
RUN go get github.com/charmbracelet/log \
18-
github.com/charmbracelet/ssh \
19-
github.com/charmbracelet/wish \
20-
github.com/charmbracelet/wish/logging \
21-
github.com/creack/pty
22-
23-
# Build the image
24-
25-
RUN env go build main.go
26-
27-
# Expose Port 22
28-
29-
EXPOSE 22
30-
31-
ENTRYPOINT ["./main"]
19+
RUN cd /app/php && composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader

0 commit comments

Comments
 (0)