Compare commits
No commits in common. "2246c597f1772a6c84ae524d9fbc0ad284961df8" and "ff75dfaa827d9b6e5e782b2a8ce996f258bd5e50" have entirely different histories.
2246c597f1
...
ff75dfaa82
7 changed files with 21 additions and 130 deletions
96
README.md
96
README.md
|
@ -2,7 +2,7 @@
|
|||
|
||||
An environment management application for PHP developers.
|
||||
|
||||
# Dev Notes
|
||||
## Dev Notes
|
||||
|
||||
**Argument priority:**
|
||||
|
||||
|
@ -10,91 +10,25 @@ An environment management application for PHP developers.
|
|||
- Any set within `{projectDirectory}/spinner.yaml`
|
||||
- Fall back to `/config/spinner.yaml`
|
||||
|
||||
# Commands
|
||||
## Commands
|
||||
|
||||
## Command: `spin:up`
|
||||
### `spin:up`
|
||||
|
||||
Creates a new PHP development environment and mounts your project files.
|
||||
#### Arguments
|
||||
|
||||
### Arguments
|
||||
- `name` - **Required**: The name for your Docker containers.
|
||||
- `path` - **Required**: The **absolute path** to your project root directory.
|
||||
- `php` - **Optional**: If passed, sets the PHP version used by your container. Can be overridden
|
||||
by creating a `spinner.yaml` file in your project root directory and defining the key `options.environment.php.version`
|
||||
|
||||
> #### Argument: name
|
||||
>
|
||||
> **Required?** ✅
|
||||
>
|
||||
> The name of your Docker containers. Your containers will spin up with the name {name}-{service}-1 i.e.
|
||||
>
|
||||
> `spinner spin:up name=test path=/path`
|
||||
>
|
||||
> Results in containers named `test-php-1` and `test-nginx-1`
|
||||
#### Options
|
||||
|
||||
> #### Argument: path
|
||||
>
|
||||
> **Required?** ✅
|
||||
>
|
||||
> The **absolute path** on your system to the project you want to create containers for.
|
||||
- `disable-node` - **Optional**: Disables Node. Can also define the key `options.environment.node.enabled` in your
|
||||
`spinner.yaml` file.
|
||||
- `disable-server` - **Optional:** Does not install a web server.
|
||||
|
||||
### Options
|
||||
## Example Usage
|
||||
|
||||
> #### Option: --php
|
||||
>
|
||||
> **Required?** ❌
|
||||
>
|
||||
> Defines the PHP version that your container will use. You can omit this flag and set the PHP version inside your
|
||||
> projects `spinner.yaml` file. Otherwise, will use the default value found in `config/spinner.yaml`
|
||||
`spinner spin:up name=test path=/abs/path/to/project`
|
||||
|
||||
> #### Option: --node
|
||||
>
|
||||
> **Required?** ❌
|
||||
>
|
||||
> Set which version of Node to install in your container. Is ignored if the `--disable-node` flag is
|
||||
> passed, or if Node is disabled in your projects `spinner.yaml` file. Equivalent to setting `options.environment.node.version = x`
|
||||
> in your projects Spinner config.
|
||||
|
||||
> #### Option: --disable-node
|
||||
>
|
||||
> **Required?** ❌
|
||||
>
|
||||
> Disables Node for your environment, so it isn't included in your PHP container. Equivalent to setting `options.environment.node.enabled = false`
|
||||
> in your Spinner config.
|
||||
|
||||
> #### Option: --disable-server
|
||||
>
|
||||
> **Required?** ❌
|
||||
>
|
||||
> Does not install a webserver (so no Nginx). Useful if you just need a PHP container to run
|
||||
> unit tests or something.
|
||||
|
||||
> #### Option: --disable-xdebug
|
||||
>
|
||||
> **Required?** ❌
|
||||
>
|
||||
> Do not install XDebug in your environment.
|
||||
|
||||
## XDebug Setup
|
||||
|
||||
These instructions are for PHPStorm. I don't know about working with other IDE's, although they
|
||||
should be fairly universal.
|
||||
|
||||
### Server Settings
|
||||
|
||||
- `File` -> `Settings` (`Preferences` on MacOS)
|
||||
- `PHP` -> `Servers` -> `+`
|
||||
- Give your "server" a name and use the values shown below.
|
||||
|
||||
| Setting | Value |
|
||||
|-------------------------|----------------------------------------------------------------------------------------------------------------|
|
||||
| Host | 127.0.0.1 |
|
||||
| Port | **Local** port **PHP** container is running on. i.e. if your docker container shows 52033:9003, use **52033**. |
|
||||
| Debugger | Xdebug |
|
||||
| Use path mappings? | ✅ |
|
||||
| File/Directory | Select **your project root** |
|
||||
| Absolute path on server | /var/www/html |
|
||||
|
||||
### Remote Debugger
|
||||
|
||||
- `Run` -> `Edit Configurations`
|
||||
- `+` -> `PHP Remote Debug`
|
||||
- Give it a name
|
||||
- Use the server you created before
|
||||
- Use **SPINNER** as IDE key
|
||||
`spinner spin:up test /abs/path/to/project 8.4 --disable-server --disable-node`
|
|
@ -1,10 +1,6 @@
|
|||
#RUN pecl install xdebug redis \
|
||||
# && docker-php-ext-enable redis
|
||||
#
|
||||
#COPY ./xdebug.ini.tmp "${PHP_INI_DIR}/conf.d/xdebug.ini"
|
||||
#RUN docker-php-ext-install opcache > /dev/null
|
||||
#COPY ./opcache.ini "${PHP_INI_DIR}/conf.d"
|
||||
RUN pecl install xdebug redis \
|
||||
&& docker-php-ext-enable redis
|
||||
|
||||
RUN pecl install xdebug
|
||||
|
||||
COPY ./xdebug.ini "${PHP_INI_DIR}/conf.d/xdebug.ini"
|
||||
COPY ./xdebug.ini.tmp "${PHP_INI_DIR}/conf.d/xdebug.ini"
|
||||
RUN docker-php-ext-install opcache > /dev/null
|
||||
COPY ./opcache.ini "${PHP_INI_DIR}/conf.d"
|
|
@ -1,8 +0,0 @@
|
|||
[xdebug]
|
||||
zend_extension=xdebug.so
|
||||
xdebug.mode=debug,develop,coverage
|
||||
xdebug.start_with_request=yes
|
||||
xdebug.client_host=host.docker.internal
|
||||
xdebug.client_port=9003
|
||||
xdebug.idekey=SPINNER
|
||||
xdebug.log=/tmp/xdebug.log
|
|
@ -2,7 +2,6 @@ options:
|
|||
environment:
|
||||
php:
|
||||
version: 8.4
|
||||
xdebug: true
|
||||
node:
|
||||
enabled: true
|
||||
version: 23
|
||||
|
|
|
@ -71,18 +71,6 @@ class Config
|
|||
return $this->getEnvironmentOption('server', 'enabled');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function isXDebugEnabled(InputInterface $input): bool
|
||||
{
|
||||
if ($input->getOption('disable-xdebug')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->getEnvironmentOption('php', 'xdebug');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
|
@ -138,8 +126,6 @@ class Config
|
|||
DataPathInterface::CONFIG_PHP_FPM_DOCKERFILE => new SpinnerFilePath(DataPathInterface::CONFIG_PHP_FPM_DOCKERFILE),
|
||||
DataPathInterface::CONFIG_NGINX_DOCKERFILE => new SpinnerFilePath(DataPathInterface::CONFIG_NGINX_DOCKERFILE),
|
||||
'nodeDockerfileTemplate' => new SpinnerFilePath('config/php-fpm/Node.Dockerfile'),
|
||||
'xdebugIniTemplate' => new SpinnerFilePath('config/php-fpm/xdebug.ini'),
|
||||
'xdebugDockerfileTemplate' => new SpinnerFilePath('config/php-fpm/XDebug.Dockerfile'),
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -34,20 +34,10 @@ class PHPDockerFileBuilder extends AbstractFileBuilder
|
|||
$this->content = str_replace('${PHP_VERSION}', (string) $this->config->getPhpVersion($input), $this->content);
|
||||
|
||||
if ($this->config->isNodeEnabled($input)) {
|
||||
$this->addNewLine();
|
||||
$this->content .= file_get_contents($this->config->getFilePaths()->get('nodeDockerfileTemplate')->getAbsolutePath());
|
||||
$this->content .= "\r\n\r\n" . file_get_contents($this->config->getFilePaths()->get('nodeDockerfileTemplate')->getAbsolutePath());
|
||||
$this->content = str_replace('${NODE_VERSION}', (string) $this->config->getNodeVersion($input), $this->content);
|
||||
}
|
||||
|
||||
if ($this->config->isXdebugEnabled($input)) {
|
||||
$this->addNewLine();
|
||||
$this->content .= file_get_contents($this->config->getFilePaths()->get('xdebugDockerfileTemplate')->getAbsolutePath());
|
||||
file_put_contents(
|
||||
(new SpinnerFilePath(sprintf('data/environments/%s/php-fpm/xdebug.ini', $input->getArgument('name'))))->getProvidedPath(),
|
||||
file_get_contents($this->config->getFilePaths()->get('xdebugIniTemplate')->getAbsolutePath())
|
||||
);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,12 +59,6 @@ class SpinCommand extends AbstractSpinnerCommand
|
|||
InputOption::VALUE_NONE,
|
||||
'Set this flag to disable Node.js for your environment.'
|
||||
)
|
||||
->addOption(
|
||||
'disable-xdebug',
|
||||
null,
|
||||
InputOption::VALUE_NONE,
|
||||
'Set this flag to disable XDebug for your environment.'
|
||||
)
|
||||
->addOption('node', null, InputOption::VALUE_OPTIONAL, 'The Node.js version to use (e.g. 20).');
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue