docs
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
# Deployment
|
||||
|
||||
Here is an example on how you can deploy with an envoy tasks. Of course make sure to add any other relevant operations for your server setup. Such as permissions.
|
||||
|
||||
```php
|
||||
@task('deploy')
|
||||
git pull origin master
|
||||
composer install --optimize-autoloader --no-dev
|
||||
rm {{ $projectPath }}/public/live
|
||||
php artisan lucent:schemas
|
||||
php artisan lucent:livelink
|
||||
php artisan generate:static
|
||||
@endtask
|
||||
```
|
||||
@@ -0,0 +1,74 @@
|
||||
# Static Generator
|
||||
|
||||
To generate the static content of the website, lucent provides a helper class.
|
||||
|
||||
|
||||
## Laravel Command
|
||||
|
||||
Just create a command and name it as you like. Make sure to inject the StaticGenerator class.
|
||||
|
||||
```php
|
||||
public function __construct(
|
||||
public StaticGenerator $staticGenerator,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
```
|
||||
|
||||
## Redirect command
|
||||
|
||||
There are cases which is useful to create a redirect like when you have a multilingual website:
|
||||
|
||||
```php
|
||||
$this->staticGenerator->run(function ($writer) {
|
||||
$writer->createRedirect("/", "/el");
|
||||
});
|
||||
```
|
||||
|
||||
## The Writer save command
|
||||
|
||||
In order to create an html file, you have to use the writer's save command
|
||||
|
||||
The first argument is the url and the second is the rendered HTML. That's where the page classes do come handy.
|
||||
|
||||
```php
|
||||
$this->staticGenerator->run(function ($writer) {
|
||||
$writer->save("/", $this->ctx->render("homepage"));
|
||||
$writer->save("/about", $this->ctx->render("about"));
|
||||
});
|
||||
```
|
||||
|
||||
## Storage and Permissions
|
||||
|
||||
All the generated html is stored on `storage/lucent/live`
|
||||
In order to make it accessible you have to create symlink:
|
||||
|
||||
```bash
|
||||
php artisan lucent:livelink
|
||||
```
|
||||
|
||||
Now your static website is accessible in http://localhost:8000/live
|
||||
|
||||
But it would not be nice to have the **live** prefix everywhere. That's why you need to make the following tweak in the nginx vhost
|
||||
|
||||
```nginxconf
|
||||
location / {
|
||||
try_files /live$uri/index.html /live$uri $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
```
|
||||
|
||||
## Build from the Lucent UI
|
||||
|
||||
In your lucent.php config file you can define your command that is used to generate the static files:
|
||||
|
||||
```php
|
||||
"generateCommand" => "generate:static"
|
||||
```
|
||||
That way, the users will be able to initiate the build command through the user interface.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user