Skip to content

Commit

Permalink
Refactor and cleanup code, adding support for Ioncube
Browse files Browse the repository at this point in the history
  • Loading branch information
nntoan committed Apr 15, 2024
1 parent dc1365b commit 831401e
Show file tree
Hide file tree
Showing 32 changed files with 581 additions and 346 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Static analysis

on:
push:
branches: [ 3.x ]
branches: [ 1.x ]
pull_request:
branches: [ 3.x ]
branches: [ 1.x ]

jobs:
test:
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Changelog
All notable changes to valet-pro-max will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [[1.0.0]](https://github.com/weprovide/valet-plus/compare/2.4.2...3.0.0)
### What's changed
- Full rewrite of Valet+/Valet Pro Max with the following major differences between the previous versions.
- No longer a fork of Laravel's Valet, but a toolkit around Valet (valet is now a dependency).
- No more platform dependencies when running commands.
- Use command valet-pro instead of valet (for now).
- Rename .env.valet to .valet-env.php.
- Use command valet-pro elasticsearch|es use instead of valet-plus use elasticsearch|es .
- Use 127.0.0.1 as Redis host instead of /tmp/redis.sock.
- Choose which binaries to install (default all) and self-update on valet-plus install command.
- Adds dependency on Docker for Elasticsearch, see https://docs.docker.com/desktop/install/mac-install/
- Supports for Opensearch via Homebrew
19 changes: 10 additions & 9 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

## Introduction

Valet Pro Max is a development environment for macOS. No Vagrant, no Docker, no `/etc/hosts` file. This project uses
Valet **Pro Max** is a development environment for macOS. No Vagrant, no Docker, no `/etc/hosts` file. This project uses
[laravel/valet](https://github.com/laravel/valet) as a dependency.


## Installation

> :warning: Valet Pro Max requires macOS and [Homebrew](https://brew.sh/). Before installation, you should make sure that no
> :warning: Valet **Pro Max** requires macOS and [Homebrew](https://brew.sh/). Before installation, you should make sure that no
> other programs such as Apache or Nginx are binding to your local machine's port 80.
> :warning: Valet Pro Max requires [Composer](https://getcomposer.org/) to be installed. It's NOT recommended to install Composer via Homebrew.
> :warning: Valet **Pro Max** requires [Composer](https://getcomposer.org/) to be installed. It's [NOT recommended](https://github.com/nntoan/valet-pro-max/wiki/Composer) to install Composer via Homebrew.
To get started, you first need to ensure that Homebrew is up-to-date using the update command:
```shell
Expand All @@ -30,19 +30,19 @@ brew services restart php@8.1
> - Uninstall Valet+ with `valet uninstall` first.
> - Remove Valet+ package with `composer global remove weprovide/valet-plus`.
Install Valet Pro Max 1.x-dev with composer:
Install Valet **Pro Max** 1.x-dev with composer:
```shell
composer global require nntoan/valet-pro-max:1.x-dev
```

Finally, you may execute the Valet Pro Max `install` command. This will configure and install Valet Pro Max, Nginx, DnsMasq and other
Finally, you may execute the Valet **Pro Max** `install` command. This will configure and install Valet **Pro Max**, Nginx, DnsMasq and other
services. In addition, use `--help` to see all installation options.
```shell
valet-pro install
```

The daemons Valet Pro Max depends on will be configured to launch when your system starts. Once Valet Pro MAx is installed, try pinging
any `*.test` domain on your terminal using a command such as `ping foobar.test`. If Valet Pro Max is installed correctly you
The daemons Valet **Pro Max** depends on will be configured to launch when your system starts. Once Valet **Pro Max** is installed, try pinging
any `*.test` domain on your terminal using a command such as `ping foobar.test`. If Valet **Pro Max** is installed correctly you
should see this domain responding on `127.0.0.1`.

## Valet Pro Max features
Expand All @@ -65,16 +65,17 @@ Here are a few key differences compared to the original Valet:
- Rewrite/unrewrite public domain to local environment
- ~~DevTools~~
- Binaries (magerun, magerun2, drush, wp-cli, shopware-cli, shopify-cli)
- Log rotation for Valet **Pro Max** services (nginx, mysql, phpfpm). To prevent big logfiles consume all disk storage.

### Changes vs Valet+ 2
### Changes vs Valet+

- Use command `valet-pro` instead of `valet`.
- Rename `.env.valet` to `.valet-env.php`.
- Use command `valet-pro elasticsearch|es use <version>` instead of `valet use elasticsearch|es <version>`.
- Use `127.0.0.1` as Redis host instead of `/tmp/redis.sock`.
- Choose which binaries to install (default all) and self-update on `valet-pro install` command.
- Adds dependency on Docker for Elasticsearch, see https://docs.docker.com/desktop/install/mac-install/
- Adds support for OpenSearch, you can install use all base commands of ES such as: `valet-pro opensearch install`, `valet-pro opensearch|os use 1`
- Supports Opensearch using Homebrew maintainer tap.

## Credits

Expand Down
11 changes: 9 additions & 2 deletions cli/ValetProMax/AbstractDockerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(
CommandLine $cli,
Filesystem $files
) {
$this->cli = $cli;
$this->cli = $cli;
$this->files = $files;
}

Expand Down Expand Up @@ -80,6 +80,7 @@ public function getAllRunningContainers(): Collection
*
* @param $command
* @param $dir
*
* @return $this
*/
public function runCommand($command, $dir): self
Expand All @@ -104,6 +105,7 @@ public function runCommand($command, $dir): self
* Starts the Docker container by the service's name. Creates the container first, if it doesn't exist yet.
*
* @param $name
*
* @return $this
*/
public function upContainer($name): self
Expand All @@ -114,7 +116,7 @@ public function upContainer($name): self

info("Docker up version {$name} (this might take a while)...");
$installPath = $this->getComposeInstallPath($name);
$installDir = $this->getComposeInstallDir($name);
$installDir = $this->getComposeInstallDir($name);

// Copy docker-compose.yml stub to installation/running path
if (!$this->files->isDir($installDir)) {
Expand All @@ -138,6 +140,7 @@ public function upContainer($name): self
* Stops the Docker container by the service's name.
*
* @param $name
*
* @return $this
*/
public function stopContainer($name): self
Expand All @@ -159,6 +162,7 @@ public function stopContainer($name): self
* Stop and remove containers, networks, images and volumes by the service's name.
*
* @param $name
*
* @return $this
*/
public function downContainer($name): self
Expand Down Expand Up @@ -200,6 +204,7 @@ protected function getServiceName(): string
* Returns path of the docker-compose.yml stub file for the service.
*
* @param $name
*
* @return string
*/
protected function getComposeStubPath($name): string
Expand All @@ -215,6 +220,7 @@ protected function getComposeStubPath($name): string
* Returns installation path of the docker-compose.yml stub file for the service.
*
* @param $name
*
* @return string
*/
protected function getComposeInstallPath($name): string
Expand All @@ -230,6 +236,7 @@ protected function getComposeInstallPath($name): string
* Returns the directory of the installation path of the docker-compose.yml stub file for the service.
*
* @param $name
*
* @return string
*/
protected function getComposeInstallDir($name): string
Expand Down
19 changes: 12 additions & 7 deletions cli/ValetProMax/AbstractPecl.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
abstract class AbstractPecl
{
// Extension types.
const NORMAL_EXTENSION_TYPE = 'extension';
const ZEND_EXTENSION_TYPE = 'zend_extension';
protected const NORMAL_EXTENSION_TYPE = 'extension';
protected const ZEND_EXTENSION_TYPE = 'zend_extension';

/**
* Shared functionality example:
Expand All @@ -30,7 +30,7 @@ abstract class AbstractPecl
*
* @formatter:on
**/
const EXTENSIONS = [
protected const EXTENSIONS = [

];

Expand All @@ -56,6 +56,7 @@ public function __construct(CommandLine $cli, Filesystem $files, Architecture $a
*
* @param $extension
* The extension key name.
*
* @return mixed
*/
protected function getExtensionType($extension)
Expand Down Expand Up @@ -111,6 +112,7 @@ protected function getPhpVersion()
*
* @param $extension
* The extension key name.
*
* @return bool
* True if installed, false if not installed.
*/
Expand Down Expand Up @@ -143,32 +145,34 @@ public function getExtensionDirectory()
*/
public function uninstallExtensions()
{
throw new \Exception(__METHOD__.' not implemented!');
throw new \Exception(__METHOD__ . ' not implemented!');
}

/**
* Install all extensions defined in EXTENSIONS.
*
* @param bool $onlyDefaults
*
* @throws Exception if not overridden but used.
*/
public function installExtensions($onlyDefaults = true)
{
throw new \Exception(__METHOD__.' not implemented!');
throw new \Exception(__METHOD__ . ' not implemented!');
}

/**
* Check if the extension is installed.
*
* @param $extension
* The extension key name.
*
* @return bool True if installed, false if not installed.
* True if installed, false if not installed.
* @throws Exception if not overridden but used.
*/
protected function isInstalled($extension)
{
throw new \Exception(__METHOD__.' not implemented!');
throw new \Exception(__METHOD__ . ' not implemented!');
}

/**
Expand All @@ -177,11 +181,12 @@ protected function isInstalled($extension)
*
* @param $extension
* The extension key name.
*
* @return string
* @throws Exception if not overridden but used.
*/
protected function getExtensionAlias($extension)
{
throw new \Exception(__METHOD__.' not implemented!');
throw new \Exception(__METHOD__ . ' not implemented!');
}
}
4 changes: 2 additions & 2 deletions cli/ValetProMax/AbstractPhpExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public function __construct(
PhpFpm $phpFpm,
PhpExtension $phpExtension
) {
$this->brew = $brew;
$this->phpFpm = $phpFpm;
$this->brew = $brew;
$this->phpFpm = $phpFpm;
$this->phpExtension = $phpExtension;

$this->phpVersion = $this->phpFpm->parsePhpVersion($this->brew->linkedPhp());
Expand Down
13 changes: 7 additions & 6 deletions cli/ValetProMax/AbstractService.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public function __construct(
CommandLine $cli
) {
$this->configuration = $configuration;
$this->brew = $brew;
$this->files = $files;
$this->cli = $cli;
$this->brew = $brew;
$this->files = $files;
$this->cli = $cli;
}

/**
Expand Down Expand Up @@ -75,7 +75,7 @@ public function getConfigClassName(): string
public function isEnabled(): bool
{
$config = $this->configuration->read();
$name = $this->getConfigClassName();
$name = $this->getConfigClassName();

return (
isset($config[$name]) &&
Expand All @@ -88,12 +88,13 @@ public function isEnabled(): bool
* Stores the enabled state of the service in the configuration.
*
* @param bool $state
*
* @throws JsonException
*/
public function setEnabled(bool $state): void
{
$config = $this->configuration->read();
$name = $this->getConfigClassName();
$name = $this->getConfigClassName();
if (!isset($config[$name])) {
$config[$name] = [];
}
Expand All @@ -110,7 +111,7 @@ public function setEnabled(bool $state): void
public function removeEnabled(): void
{
$config = $this->configuration->read();
$name = $this->getConfigClassName();
$name = $this->getConfigClassName();
if (!isset($config[$name])) {
$config[$name] = [];
}
Expand Down
Loading

0 comments on commit 831401e

Please sign in to comment.