Compare commits

..

No commits in common. "b21d0dbfc656709f82735efc67ef5d364fa81370" and "5d1525234e817c6f8154d9e36fc3832fcb60ca13" have entirely different histories.

10 changed files with 20 additions and 54 deletions

View file

@ -2,7 +2,7 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
## [1.0.4] - 2025-04-24 ## [1.1.0] - 2025-04-24
### Fixed ### Fixed
- Fixed a critical autoloading issue after the package is globally installed. - Fixed a critical autoloading issue after the package is globally installed.
@ -22,6 +22,7 @@ All notable changes to this project will be documented in this file.
- Minor documentation tweak to make the header image display on Packagist. - Minor documentation tweak to make the header image display on Packagist.
## [1.0.0] 2025-04-24 ## [1.0.0] 2025-04-24
### Added ### Added
- Initial public release of **Loom Spinner CLI**. - Initial public release of **Loom Spinner CLI**.
- Command to spin up a new PHP development environment with Docker (`spin:up`). - Command to spin up a new PHP development environment with Docker (`spin:up`).

View file

@ -5,7 +5,7 @@
# Loom Spinner CLI # Loom Spinner CLI
<p> <p>
<img src="https://img.shields.io/badge/Version-1.0.4-blue" alt="Version 1.0.4"> <img src="https://img.shields.io/badge/Version-1.1.0-blue" alt="Version 1.1.0">
</p> </p>
A streamlined environment management tool for PHP developers. A streamlined environment management tool for PHP developers.
@ -21,13 +21,16 @@ Effortlessly create custom Docker environments for each of your PHP projects. Ou
- **PHP 8.4** (includes XDebug & OpCache) - **PHP 8.4** (includes XDebug & OpCache)
- **Nginx** - **Nginx**
- **MySQL 9.3** - **SQLite3**
- **NodeJS 23** (Node, NPM, & NPX) - **NodeJS 23** (Node, NPM, & NPX)
Your project directory is automatically mounted to the PHP container, and the `public` directory is served via Nginx at Your project directory is automatically mounted to the PHP container, and the `public` directory is served via Nginx at
`http://localhost:<nginx-port>`. Access the container directly from your terminal to execute unit tests or other `http://localhost:<nginx-port>`. Access the container directly from your terminal to execute unit tests or other
commands, all within an isolated environment. commands, all within an isolated environment.
> **Note:** Loom Spinner CLI is in early development. For now, only SQLite is supported as the database, but more options
> are on the way in future updates.
# Installation # Installation
**Requirements:** **Requirements:**

View file

@ -1,7 +1,7 @@
{ {
"name": "loomlabs/loom-spinner-cli", "name": "loomlabs/loom-spinner-cli",
"description": "A simple command-line Docker environment spinner for PHP.", "description": "A simple command-line Docker environment spinner for PHP.",
"version": "1.0.4", "version": "1.1.0",
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Loom\\Spinner\\": "src/" "Loom\\Spinner\\": "src/"

View file

@ -7,8 +7,4 @@ PHP_VERSION=%s
PHP_PORT=%s PHP_PORT=%s
# Nginx # Nginx
SERVER_PORT=%s NGINX_PORT=%s
# Database
DATABASE_PORT=%s
ROOT_PASSWORD=%s

View file

@ -1,12 +0,0 @@
services:
mysql:
image: mysql:9.3.0
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci
ports:
- ${DATABASE_PORT}:3306
expose:
- "3306"
environment:
MYSQL_ROOT_PASSWORD: ${ROOT_PASSWORD}
volumes:
- ./data/${PROJECT_NAME}/mysql:/var/lib/mysql:cached

View file

@ -3,7 +3,7 @@ services:
build: build:
context: ./nginx context: ./nginx
ports: ports:
- ${SERVER_PORT}:80 - ${NGINX_PORT}:80
volumes: volumes:
- ${PROJECT_DIRECTORY}:/var/www/html:cached - ${PROJECT_DIRECTORY}:/var/www/html:cached
- ./nginx/conf.d:/etc/nginx/conf.d - ./nginx/conf.d:/etc/nginx/conf.d

View file

@ -9,5 +9,4 @@ options:
enabled: true enabled: true
database: database:
enabled: true enabled: true
driver: mysql driver: sqlite3
rootPassword: docker

View file

@ -13,7 +13,7 @@ class DockerComposeFileBuilder extends AbstractFileBuilder
/** /**
* @throws \Exception * @throws \Exception
*/ */
public function __construct(Config $config, private array $ports) public function __construct(Config $config)
{ {
return parent::__construct($config->getDataDirectory() . '/docker-compose.yaml', $config); return parent::__construct($config->getDataDirectory() . '/docker-compose.yaml', $config);
} }
@ -25,16 +25,8 @@ class DockerComposeFileBuilder extends AbstractFileBuilder
{ {
$this->content = $this->config->getConfigFileContents('php.yaml'); $this->content = $this->config->getConfigFileContents('php.yaml');
if ($this->config->isDatabaseEnabled($input)) { if ($this->config->isDatabaseEnabled($input) && in_array($this->config->getDatabaseDriver($input), ['sqlite3', 'sqlite'])) {
$databaseDriver = strtolower($this->config->getDatabaseDriver($input)); $this->addSqliteDatabaseConfig();
if (in_array($databaseDriver, ['sqlite3', 'sqlite'])) {
$this->addSqliteDatabaseConfig();
}
if ($databaseDriver === 'mysql') {
$this->addMysqlDatabaseConfig();
}
} }
if ($this->config->isServerEnabled($input)) { if ($this->config->isServerEnabled($input)) {
@ -64,12 +56,4 @@ class DockerComposeFileBuilder extends AbstractFileBuilder
$sqlLiteConfig = str_replace('volumes:', '', $sqlLiteConfig); $sqlLiteConfig = str_replace('volumes:', '', $sqlLiteConfig);
$this->content .= $sqlLiteConfig; $this->content .= $sqlLiteConfig;
} }
private function addMysqlDatabaseConfig(): void
{
$mysqlConfig = str_replace('services:', '', $this->config->getConfigFileContents('mysql.yaml'));
$mysqlConfig = str_replace('${ROOT_PASSWORD}', $this->config->getEnvironmentOption('database', 'rootPassword'), $mysqlConfig);
$mysqlConfig = str_replace('${DATABASE_PORT}', (string) $this->ports['database'], $mysqlConfig);
$this->content.= $mysqlConfig;
}
} }

View file

@ -31,11 +31,9 @@ class PHPDockerFileBuilder extends AbstractFileBuilder
$this->config->getConfigFileContents('php-fpm/opcache.ini') $this->config->getConfigFileContents('php-fpm/opcache.ini')
); );
if ($this->config->isDatabaseEnabled($input)) { if ($this->config->isDatabaseEnabled($input) && in_array($this->config->getDatabaseDriver($input), ['sqlite3', 'sqlite'])) {
if (in_array($this->config->getDatabaseDriver($input), ['sqlite3', 'sqlite'])) { $this->addNewLine();
$this->addNewLine(); $this->content .= $this->config->getConfigFileContents('php-fpm/Sqlite.Dockerfile');
$this->content .= $this->config->getConfigFileContents('php-fpm/Sqlite.Dockerfile');
}
} }
$this->content = str_replace('${NODE_VERSION}', (string) $this->config->getNodeVersion($input), $this->content); $this->content = str_replace('${NODE_VERSION}', (string) $this->config->getNodeVersion($input), $this->content);

View file

@ -28,8 +28,7 @@ class SpinCommand extends AbstractSpinnerCommand
$this->portGenerator = new PortGenerator(); $this->portGenerator = new PortGenerator();
$this->ports = [ $this->ports = [
'php' => $this->portGenerator->generateRandomPort(), 'php' => $this->portGenerator->generateRandomPort(),
'server' => $this->portGenerator->generateRandomPort(), 'nginx' => $this->portGenerator->generateRandomPort(),
'database' => $this->portGenerator->generateRandomPort(),
]; ];
parent::__construct(); parent::__construct();
@ -155,9 +154,7 @@ class SpinCommand extends AbstractSpinnerCommand
$input->getArgument('name'), $input->getArgument('name'),
$this->config->getPhpVersion($input), $this->config->getPhpVersion($input),
$this->ports['php'], $this->ports['php'],
$this->ports['server'], $this->ports['nginx'],
$this->ports['database'],
$this->config->getEnvironmentOption('database', 'rootPassword')
) )
); );
} }
@ -169,7 +166,7 @@ class SpinCommand extends AbstractSpinnerCommand
{ {
$this->createProjectDataSubDirectory('php-fpm'); $this->createProjectDataSubDirectory('php-fpm');
(new DockerComposeFileBuilder($this->config, $this->ports))->build($input)->save(); (new DockerComposeFileBuilder($this->config))->build($input)->save();
} }
/** /**