Skip to content

Commit 60fc884

Browse files
authored
Merge pull request #23 from yceruto/local_server
Add documentation to use Symfony local webserver
2 parents 22ab29d + 29270c5 commit 60fc884

File tree

1 file changed

+56
-22
lines changed

1 file changed

+56
-22
lines changed

README.md

Lines changed: 56 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,60 @@ Following the same philosophy since Symfony 4, as well as you can set environmen
5555
$ APP_CONTEXT=admin php -S 127.0.0.1:8000 -t public
5656
$ APP_CONTEXT=api php -S 127.0.0.1:8001 -t public
5757

58+
### Use Symfony local webserver
59+
60+
You will need to use [Symfony local server](https://symfony.com/doc/current/setup/symfony_server.html) and its [proxy](https://symfony.com/doc/current/setup/symfony_server.html#setting-up-the-local-proxy).
61+
62+
First, start Symfony proxy by doing `symfony proxy:start` in the project folder.
63+
64+
Then, create a [symlink](https://en.wikipedia.org/wiki/Symbolic_link) pointing to your project folder for each of your applications. You can keep them in a folder in your project or outside it, as you prefer.
65+
66+
├── applications/
67+
│ ├── admin
68+
| ├── api
69+
| └── site
70+
├── config/
71+
├── src/
72+
└── var/
73+
74+
Next, you'll need to configure each local server and start it. To do so, you will use the created symlinks, like so:
75+
76+
```
77+
# start admin local server
78+
APP_CONTEXT=admin symfony proxy:domain:attach admin --dir=[project folder path]/applications/admin
79+
APP_CONTEXT=admin symfony server:start --dir=[project folder path]/applications/admin
80+
81+
# start api local server
82+
APP_CONTEXT=api symfony proxy:domain:attach api --dir=[project folder path]/applications/api
83+
APP_CONTEXT=api symfony server:start --dir=[project folder path]/applications/api
84+
85+
# start site local server
86+
APP_CONTEXT=site symfony proxy:domain:attach site --dir=[project folder path]/applications/site
87+
APP_CONTEXT=site symfony server:start --dir=[project folder path]/applications/site
88+
```
89+
90+
To check if each server is running, you can go to [localhost:7080](http://localhost:7080).
91+
92+
### Production and vhosts
93+
94+
Set the environment variable `APP_CONTEXT` for each vhost config in your production server and development machine if preferred:
95+
96+
<VirtualHost admin.company.com:80>
97+
# ...
98+
99+
SetEnv APP_CONTEXT admin
100+
101+
# ...
102+
</VirtualHost>
103+
104+
<VirtualHost api.company.com:80>
105+
# ...
106+
107+
SetEnv APP_CONTEXT api
108+
109+
# ...
110+
</VirtualHost>
111+
58112
### Executing commands per application
59113

60114
├── bin/
@@ -63,7 +117,7 @@ Following the same philosophy since Symfony 4, as well as you can set environmen
63117
Use `--kernel`, `-k` option to run any command for one specific app:
64118

65119
$ bin/console about -k api
66-
120+
67121
Or if you prefer, use environment variables on CLI:
68122

69123
$ export APP_CONTEXT=api
@@ -91,29 +145,9 @@ The `tests` directory is pretty similar to `src` directory, just update your `co
91145
},
92146

93147
Run `composer dump-autoload` to re-generate the autoload config.
94-
95-
Here, creates a `<CONTEXT>WebTestCase` class per app in order to execute all tests together.
96148

97-
### Production and vhosts
98-
99-
Set the environment variable `APP_CONTEXT` for each vhost config in your production server and development machine if preferred:
100-
101-
<VirtualHost admin.company.com:80>
102-
# ...
103-
104-
SetEnv APP_CONTEXT admin
105-
106-
# ...
107-
</VirtualHost>
149+
Here, creates a `<CONTEXT>WebTestCase` class per app in order to execute all tests together.
108150

109-
<VirtualHost api.company.com:80>
110-
# ...
111-
112-
SetEnv APP_CONTEXT api
113-
114-
# ...
115-
</VirtualHost>
116-
117151
### Adding more applications to the project
118152

119153
Run `bin/console make:app-context <CONTEXT>` to create a new application context skeleton.

0 commit comments

Comments
 (0)