Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dx 469/test devenv #1162

Merged
merged 7 commits into from
Nov 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 98 additions & 32 deletions guides/installation/devenv.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ You probably won't be able to use the commands below. Use the following steps to
```

* Copy these lines and delete them from this file.
* Open `~/.zshrc` and add the above copied lines to the end of this file.
* Open `~/.zshrc` and add the above-copied lines to the end of this file.
* Initiate the terminal with `source ~/.zshrc` or reboot your terminal for nix to work.

[Credits: "nixos installation issue,'command not found: nix'", StackOverflow](https://stackoverflow.com/a/70822086/982278)
Expand Down Expand Up @@ -127,13 +127,17 @@ You can find the whole installation guide for devenv in their official documenta

### Shopware

Depending on whether you want to set up a fresh Shopware project or contribute to the Shopware core, choose between:
Depending on whether you want to set up a fresh Shopware project or contribute to the Shopware core, you have to choose between the [Symfony Flex template](template) or the Shopware project.

<Tabs>
<Tab title="Symfony Flex">
If you are already using Symfony Flex, you require a Composer package to get a basic devenv configuration:
If you are already using our Symfony Flex template, you require a Composer package to get a basic devenv configuration:

```bash
```shell
cd <YOUR_SHOPWARE_FLEX_PROJECT_ROOT>
```

```shell
composer require devenv
```

Expand All @@ -160,6 +164,26 @@ devenv up
Make sure that the ports for the services are not already in use, or else the command will fail.
:::

Check your default web services with the following commands:

<Tabs>
<Tab title="macOS">

```bash
netstat -p tcp -van | grep '^Proto\|LISTEN'
```

</Tab>

<Tab title="Ubuntu">

```bash
ss -tulpn | grep ':80\|:3306\|:6379'
```

</Tab>
</Tabs>

Ensure to change your `.env` file to have the database connect using localhost's IP address instead of the default MySQL socket:

```txt
Expand Down Expand Up @@ -212,7 +236,7 @@ The installation instructions for other OS are available on direnv's [official d
</Tab>
</Tabs>

Afterwards, add the following hook to your shell:
Afterward, add the following hook to your shell:

<Tabs>

Expand Down Expand Up @@ -261,13 +285,27 @@ direnv allow

Here is an overview of services Shopware provides by default and how you can access them:

| Service | Access |
|------------------|------------------------------------------------|
| MySQL | `mysql://shopware:[email protected]:3306` |
| Caddy | [http://localhost:8000](http://localhost:8000) |
| Adminer | [http://localhost:9080](http://localhost:9080) |
| Mailhog (SMTP) | `smtp://127.0.0.1:1025` |
| Mailhog (Web UI) | [http://localhost:8025](http://localhost:8025) |
| Service | Access |
|----------------|-------------------------------------------------|
| MySQL | `mysql://shopware:[email protected]:3306` |
| Mailhog (SMTP) | `smtp://127.0.0.1:1025` |
| Redis (TCP) | `tcp://127.0.0.1:6379` |

### Caddy
Caddy is a powerful, enterprise-ready, open-source web server with automatic HTTPS written in Go.

[http://127.0.0.1:8000](http://127.0.0.1:8000)

### Adminer
Adminer is a full-featured database management tool written in PHP.

[http://localhost:8010](http://localhost:8010)

### Mailhog
MailHog is an email testing tool for developers.

[http://localhost:8025](http://localhost:8025)


## Customize your setup

Expand Down Expand Up @@ -301,7 +339,7 @@ After changing `devenv.local.nix`, please [reload your environment](#manually-re
};

# Override an environment variable
env.APP_URL = "http://shopware.swag";
env.APP_URL = "http://shopware.swag:YOUR_CADDY_PORT";
}
```

Expand Down Expand Up @@ -370,30 +408,46 @@ Refer to the official devenv documentation to get a complete list of all availab

### Use customized VirtualHosts port for Caddy

<Tabs>
<Tab title="Port">

```nix
// <PROJECT_ROOT>/devenv.local.nix
{ pkgs, config, lib, ... }:
Isengo1989 marked this conversation as resolved.
Show resolved Hide resolved

{
services.caddy.virtualHosts = lib.mkForce {
":8029" = lib.mkDefault {
extraConfig = lib.mkDefault ''
@default {
not path /theme/* /media/* /thumbnail/* /bundles/* /css/* /fonts/* /js/* /sitemap/*
}

root * public
php_fastcgi @default unix/${config.languages.php.fpm.pools.web.socket} {
trusted_proxies private_ranges
}
file_server
'';
};
};

services.caddy.virtualHosts.":8029" = {
extraConfig = ''
root * public
php_fastcgi unix/${config.languages.php.fpm.pools.web.socket}
file_server
'';
};
}
```

</Tab>

<Tab title="Port and virtual host">

```nix
// <PROJECT_ROOT>/devenv.local.nix
{ pkgs, config, lib, ... }:

{
services.caddy.virtualHosts."http://shopware.swag:8029" = {
extraConfig = ''
root * public
php_fastcgi unix/${config.languages.php.fpm.pools.web.socket}
file_server
'';
};
```

</Tab>
</Tabs>


### Use customized Adminer port

```nix
Expand All @@ -417,16 +471,28 @@ devenv shell

### Direnv slow in big projects

The bigger your project directory is getting over time (e.g. cache files piling up), the slower direnv will be.
This is a known issue and the devenv developers are working on a solution.
The bigger your project directory is getting over time (e.g., cache files piling up), the slower direnv will be.
This is a known issue, and the devenv developers are working on a solution.

<PageRef page="https://github.com/cachix/devenv/issues/257" title="Devenv slows down with big code repositories #257" target="_blank" />

### Fail to start Redis with locale other than en_US

```shell
14:04:52 redis.1 | 364812:M 07 Nov 2023 14:04:52.999 # Failed to configure LOCALE for invalid locale name.
```

You can export a different locale to your shell with the following command:

```shell
export LANG=en_US.UTF8;
```

## FAQ

### How do I clean up devenv?

Periodically run `devenv gc` to remove orphaned services, packages and processes and free up disk space.
Periodically run `devenv gc` to remove orphaned services, packages and processes and free-up disk space.

### How do I access the database?

Expand Down
Loading