Skip to content

Commit

Permalink
Merge pull request #127 from genesisweb/php-helper
Browse files Browse the repository at this point in the history
V2 - PHP Binary Helper
  • Loading branch information
uttamrabadiya authored Jun 8, 2024
2 parents b46d323 + 1870326 commit 467c620
Show file tree
Hide file tree
Showing 95 changed files with 8,213 additions and 2,470 deletions.
31 changes: 25 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
name: CI-Ubuntu
name: CI

on: [pull_request]

jobs:
build:
name: Build & Test on Ubuntu 22.04
test:
name: Build & Test
runs-on: ubuntu-22.04
if: github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'master'
strategy:
matrix:
php:
- 8.0
- 8.1
- 8.2
- 8.3
steps:
- uses: actions/checkout@v2
- name: Set up PHP
Expand All @@ -25,3 +24,23 @@ jobs:
composer install --no-interaction --prefer-dist
- name: Test
run: vendor/bin/phpunit
cs_fixer:
name: CS Fixer
runs-on: ubuntu-22.04
strategy:
matrix:
php:
- 8.3
steps:
- uses: actions/checkout@v2
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y network-manager libnss3-tools jq xsel
composer install --no-interaction --prefer-dist
- name: CS Fixer
run: vendor/bin/php-cs-fixer check --config=.php-cs-fixer.dist.php
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
vendor/
bin/
tests/config
composer.lock
error.log
*.sublime-project
*.sublime-workspace
psysh
Gemfile
Gemfile.lock
_site/
.idea
/.php-cs-fixer.cache
.php-cs-fixer.cache
.phpunit.result.cache
56 changes: 56 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

$finder = (new PhpCsFixer\Finder())
->in([
__DIR__.'/cli/',
__DIR__.'/tests/'
]);

$config = new PhpCsFixer\Config();
return $config
->setRiskyAllowed(true)
->setUsingCache(false)
->setRules([
'@PSR12' => true,
'list_syntax' => ['syntax' => 'short'],
'multiline_comment_opening_closing' => true,
'no_blank_lines_after_phpdoc' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_blank_lines' => true,
'no_spaces_after_function_name' => true,
'no_superfluous_elseif' => true,
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
'no_unused_imports' => true,
'no_useless_else' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'object_operator_without_whitespace' => true,
'ordered_imports' => ['sort_algorithm' => 'alpha', 'imports_order' => ['class', 'function', 'const']],
'php_unit_construct' => true,
'php_unit_expectation' => true,
'php_unit_mock' => ['target' => 'newest'],
'php_unit_mock_short_will_return' => true,
'php_unit_no_expectation_annotation' => true,
'php_unit_test_case_static_method_calls' => ['call_type' => 'this'],
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_line_span' => ['method' => 'multi', 'property' => 'multi'],
'phpdoc_no_useless_inheritdoc' => true,
'phpdoc_scalar' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_trim' => true,
'phpdoc_trim_consecutive_blank_line_separation' => true,
'phpdoc_types' => true,
'phpdoc_var_annotation_correct_order' => true,
'phpdoc_var_without_name' => true,
'protected_to_private' => true,
'return_assignment' => true,
'short_scalar_cast' => true,
'single_trait_insert_per_statement' => true,
'standardize_not_equals' => true,
'trim_array_spaces' => true,
'visibility_required' => ['elements' => ['const']],
'whitespace_after_comma_in_array' => true,
])
->setFinder($finder);
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<p align="center"><img width="500" src="art/logo.png"></p>

<p align="center">
<a href="https://github.styleci.io/repos/218757845"><img src="https://github.styleci.io/repos/218757845/shield?branch=master" alt="StyleCI"></a>
<a href="https://scrutinizer-ci.com/g/genesisweb/valet-linux-plus/?branch=master"><img src="https://scrutinizer-ci.com/g/genesisweb/valet-linux-plus/badges/quality-score.png?b=master" alt="Scrutinizer"></a>
<a href="https://packagist.org/packages/genesisweb/valet-linux-plus"><img src="https://poser.pugx.org/genesisweb/valet-linux-plus/downloads.svg" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/genesisweb/valet-linux-plus"><img src="https://poser.pugx.org/genesisweb/valet-linux-plus/v/stable.svg" alt="Latest Stable Version"></a>
Expand Down
40 changes: 27 additions & 13 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
1. Finish refactoring classes in Valet directory -- Done
2. Fix facade.php -- Done
3. Move config directory from ~/.valet to ~/.config/valet
3.1 Copy directory from ~/.valet to ~/.config
3.2 Replace /home/uttam/.valet path with /home/uttam/.config/valet for Nginx directory files (Logs & Certificate, .sock files)
3.3 Replace .sock file paths in valet.conf file.
3.4 Regenerate symbolic links in Sites directory
4. Add relevant test cases
5. Enable Phpstan & CodeSniffer -- Done
6. Enable unit coverage report
7. Add Infection
8. Ngrok remove binary file and install it via `valet install` command
9. self-signed certificate verification issues in Firefox & PHP's curl requests
Remain Items:
- Enable unit coverage report
- Add Infection
- Valet php extension install separately so that if not installed we can install it via valet install command. (Optional)
- Improve valet uninstall experience
- User should be able to select which services they want to uninstall
- mbstring extension was not installed in system, but composer install command fail to stop process as it was mentioned in required json


Done Items:
- Implement termwind -- Done
- Fix extra messages (Fixing, already enabled, restarting) -- Done
- Remove was already enabled message -- Done
- Enable Phpstan & CodeSniffer -- Done
- Finish refactoring classes in Valet directory -- Done
- Fix facade.php -- Done
- Move config directory from ~/.valet to ~/.config/valet -- Done
- Update valet use command to only work with current supported PHP versions
- Update valet isolate command to work with every php version from 7.0 to latest
- Optimise php bash file to handle blank output of which-php command
- self-signed certificate verification issues in Firefox & PHP's curl requests -- Done
- Ngrok remove binary file and install it via `valet install` command
- Optimise PHP Bash file to not relay on which-php command
- It should read fallback version from ~/.config/valet/config.json file
- It should read isolated version for directory from ~/.config/valet/config.json file
- Add relevant test cases
-
14 changes: 3 additions & 11 deletions cli/Valet/CommandLine.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,13 @@ public function runAsUser(string $command, callable $onError = null): string

/**
* Run the given command.
* TODO: Refactor new Process instance, we might not need if statement there.
*/
private function runCommand(string $command, callable $onError = null): string
{
$onError = $onError ?: function () {};
$onError = $onError ?: function () {
};

// Symfony's 4.x Process component has deprecated passing a command string
// to the constructor, but older versions (which Valet's Composer
// constraints allow) don't have the fromShellCommandLine method.
// For more information, see: https://github.com/laravel/valet/pull/761
if (method_exists(Process::class, 'fromShellCommandline')) {
$process = Process::fromShellCommandline($command);
} else {
$process = new Process($command);
}
$process = Process::fromShellCommandline($command);

$processOutput = '';
$process->setTimeout(null)->run(function ($type, $line) use (&$processOutput) {
Expand Down
Loading

0 comments on commit 467c620

Please sign in to comment.