Skip to content

Commit db29b5b

Browse files
committed
fix: patch up broken links
1 parent 79543e0 commit db29b5b

File tree

7 files changed

+172
-12
lines changed

7 files changed

+172
-12
lines changed

.vitepress/config/sidebar.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ const sidebar = [
173173
// items: [
174174
// { text: 'Intro', link: '/codelabs/' },
175175
// { text: 'Contributing', link: '/codelabs/contributing' },
176-
// // { text: 'Deployment', link: '/codelabs/experiments/deployment/' },
177-
// // { text: 'Authentication', link: '/codelabs/experiments/auth/' },
176+
// // { text: 'Deployment', link: '/learn/deployment/' },
177+
// // { text: 'Authentication', link: '/learn/auth/' },
178178
// ],
179179
// },
180180
];

src/docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ Most PHP frameworks are complex, slow, and opinionated. Leaf is different—it's
3838

3939
## Creating a new app
4040

41-
Leaf is built to be incrementally adoptable: use it as a lightweight core for small to medium apps, or scale up with [Leaf MVC](/docs/mvc) for more structure in complex applications. No matter your stack, Leaf stays simple, fast, and developer-friendly—so you can build and ship with ease.
41+
Leaf is built to be incrementally adoptable: use it as a lightweight core for small to medium apps, or scale up with [Leaf MVC](/docs/mvc/) for more structure in complex applications. No matter your stack, Leaf stays simple, fast, and developer-friendly—so you can build and ship with ease.
4242

4343
::: details Technical Requirements
4444

45-
Before you start with Leaf, verify that your system has PHP v7.4+, Composer (for package management) and [Leaf CLI](/docs/cli) (optional but recommended for easier app management)
45+
Before you start with Leaf, verify that your system has PHP v7.4+, Composer (for package management) and [Leaf CLI](/docs/cli/) (optional but recommended for easier app management)
4646

4747
::: details Don't have PHP & Composer installed?
4848

src/learn/basic.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Once you are in your application root, you can run the app using the `serve` com
7575
php leaf serve
7676
```
7777

78-
Your app is now running! Open [http://localhost:5500](http://localhost:5500) in your browser.
78+
Your app is now running! Open <a href="http://localhost:5500" target="_blank" rel="noreferrer">http://localhost:5500</a> in your browser.
7979

8080
## Building your first app
8181

@@ -162,7 +162,7 @@ Okay, looks like some magic is happening here. Let's break it down:
162162
- `app()` is a helper function that gives you access to the Leaf app instance, it is available from anywhere in your app.
163163
- `view()` is a method that you can use to create a route that renders a Blade view. The first argument is what the user enters in the URL, and the second argument is the name of the view file to render.
164164

165-
Notice we did not have to configure Blade because Leaf does that for you. You can now navigate to [http://localhost:5500/prelaunch](http://localhost:5500/prelaunch) to see your pre-launch page.
165+
Notice we did not have to configure Blade because Leaf does that for you. You can now navigate to http://localhost:5500/prelaunch to see your pre-launch page.
166166

167167
### <span class="bg-[var(--vp-c-bg-alt)] h-6 inline-flex items-center justify-center rounded-full text-gray-700 dark:text-gray-300 text-lg w-6 mr-1 flex-none font-normal">2</span> Handling the form submission
168168

@@ -298,7 +298,7 @@ You can use the `withFlash()` method to send a message to the next request. This
298298

299299
### <span class="bg-[var(--vp-c-bg-alt)] h-6 inline-flex items-center justify-center rounded-full text-gray-700 dark:text-gray-300 text-lg w-6 mr-1 flex-none font-normal">5</span> Deploying your app
300300

301-
We have built a simple pre-launch page using Leaf. You can now deploy your app to a server using a service like [Heroku](/learn/deployment/heroku), [Fly.io](/learn/deployment/flyio) a VPS like [DigitalOcean](/learn/deployment/digitalocean), or even a shared hosting service like [Sevalla](/learn/deployment/sevalla).
301+
We have built a simple pre-launch page using Leaf. You can now deploy your app to a server using a service like [Heroku](/learn/deployment/heroku/), [Fly.io](/learn/deployment/flyio/) a VPS like [DigitalOcean](/learn/deployment/digitalocean/), or even a shared hosting service like [Sevalla](/learn/deployment/sevalla/).
302302

303303
<div class="my-4 md:my-10">
304304
<div
File renamed without changes.

src/learn/deployment/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ This is a collection of codelab experiments related to deployment across differe
44

55
| Provider | Description |
66
| :-------------------------------------------------------------- | :--------------------------------------------------------- |
7-
| [Digital Ocean](/codelabs/experiments/deployment/digitalocean/) | Deploying LeafMVC projects to a new Digital Ocean droplet |
8-
| [Heroku](/codelabs/experiments/deployment/heroku/) | Deploying a base Leaf project to Heroku using the Leaf CLI |
9-
| [Fly.io](/codelabs/experiments/deployment/fly.io/) | Deploying a base Leaf application to Fly.io |
7+
| [Digital Ocean](/learn/deployment/digitalocean/) | Deploying LeafMVC projects to a new Digital Ocean droplet |
8+
| [Heroku](/learn/deployment/heroku/) | Deploying a base Leaf project to Heroku using the Leaf CLI |
9+
| [Fly.io](/learn/deployment/flyio/) | Deploying a base Leaf application to Fly.io |
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
---
2+
sidebar: false
3+
editLink: false
4+
prev: false
5+
next: false
6+
lastUpdated: false
7+
---
8+
9+
# Deploying a LeafMVC Application to Digital Ocean
10+
11+
::: warning Version support
12+
Version support. This tutorial assumes use of LeafPHP >= 3.0 and PHP >=7.0.
13+
:::
14+
15+
## What Are We Building
16+
17+
This experiment will guide you deploying your first LeafMVC application to Digital Ocean. A majority
18+
of the same steps apply to Leaf v3 core as well.
19+
20+
::: details (New to Digital Ocean?)
21+
Digital Ocean is a cloud service provider that offers great introductory pricing for virtual private
22+
servers (VPS). Create an account, tether a credit card, and prepare to build.
23+
:::
24+
25+
## Prerequisites
26+
27+
Before continuing, it is important to determine if you would like to purhcase or point a domain name
28+
to the VPS you are about to spin up. $DOMAIN will be shown several times throughout this experiment
29+
and should be replaced by either your domain name (example.com) or the Droplet's public IP address. You
30+
can grab the public IP address from the Digital Ocean control panel.
31+
32+
For instructions on how to setup a domain with Digital Ocean, [click here](https://docs.digitalocean.com/products/networking/dns/how-to/add-domains/).
33+
34+
## 1. Create a new droplet
35+
36+
From the control panel, click the green "Create" button and select droplet. We will create a VPS with the
37+
following options selected:
38+
39+
* Ubuntu: 20.04 (LTS)
40+
* Plan: Basic
41+
* CPU Options: Premium AMD or Regular Intel
42+
* $6/mo package
43+
44+
::: tip Scaling ⚡️
45+
Should your application grow in requirements or traffic, you can always come back and increase your package selection.
46+
:::
47+
48+
### Authentication
49+
50+
It is highly recommended that your utilize SSH-based authentication. Select an existing key, or [generate a new key](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent), then add it.
51+
52+
## 2. Initial droplet setup
53+
54+
After your droplet has been created, you will need to login, secure it, and install required software. The first task will
55+
be to create an admin user, then utilie that account for future SSH connections.
56+
57+
```bash
58+
ssh root@$DOMAIN
59+
adduser username
60+
usermod -aG sudo username
61+
rsync --archive --chown=username:username ~/.ssh /home/username
62+
```
63+
64+
Test the admin account: ``su - username``. If the command executes, you can terminal the SSH session and log
65+
back in with your new user account (recommended).
66+
67+
### Setup firewall
68+
69+
Next we will setup UFW - Ubuntu Firewall. We will allow communication on ports: 22 (SSH), 80 (HTTP), and 443 (SSL).
70+
71+
```bash
72+
sudo ufw allow 22
73+
sudo ufw allow 80
74+
sudo ufw allow 443
75+
sudo ufw enable
76+
```
77+
78+
After creating the firewall's rules and enabling UFW, you can view firewall status by ``sudo ufw status``.
79+
80+
### Install required software
81+
82+
It is now time install all of the needed software to enable LeafPHP to run. First, we need to update all system software:
83+
84+
```bash
85+
sudo apt update
86+
sudo apt upgrade
87+
```
88+
89+
Be sure to respond **Y** when asked to continue. Now we can intall NGINX, PHP, MySQL, and curl.
90+
91+
```bash
92+
sudo apt install nginx php-fpm php-mysql php-curl
93+
```
94+
95+
Once complete, follow the
96+
[NGINX instructions](https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-ubuntu-18-04#step-3-%E2%80%93-installing-php-and-configuring-nginx-to-use-the-php-processor).
97+
Ensure that your directory is set as such: `` root /var/www/$DOMAIN/public;`` Below is an example sites-available file.
98+
99+
```nginx
100+
server {
101+
server_name itsglint.com www.itsglint.com 147.182.136.153;
102+
root /var/www/itsglint.com/public;
103+
104+
index index.html index.htm index.php;
105+
106+
location / {
107+
try_files $uri /index.php?$query_string;
108+
}
109+
110+
location ~ \.php$ {
111+
include snippets/fastcgi-php.conf;
112+
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
113+
}
114+
}
115+
```
116+
117+
::: warning Leaf Router and .htaccess support
118+
It is important to mirror the location blocks as-in. Otherwise, LeafRouter will not work properly or at all.
119+
:::
120+
121+
Next, we will install Mysql. Follow the [install instructions](https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-ubuntu-18-04#step-2-%E2%80%93-installing-mysql-to-manage-site-data).
122+
123+
```bash
124+
sudo apt install mysql-server
125+
```
126+
127+
### Install your Leaf🍁 application
128+
129+
Next, we will download and install our application with all dependencies. Clone your repository from Github,
130+
or any source, and place your Leaf project in ``/var/www/$DOMAIN``. Afterwards, install required dependencies
131+
and perform initial Leaf tasks:
132+
133+
```bash
134+
composer install
135+
php leaf db:install
136+
php leaf db:migrate
137+
```
138+
139+
You also may seed the database if required: `php leaf db:seed`.
140+
141+
Congratulations 🎉, you now have a fully working production server, and should be able to reach your application at $DOMAIN.
142+
143+
::: details Recommended: Complete SSL Setup
144+
If your Leaf applications is more than a hobbyist adventure and serving actual clients or visitors, it is
145+
strongly recommended to complete the SSL setup. SSL encrypts traffic between a browser and server. Replace
146+
example.com with $DOMAIN.
147+
148+
```
149+
sudo apt install certbot python3-certbot-nginx
150+
sudo systemctl reload nginx
151+
sudo certbot --nginx -d example.com -d www.example.com
152+
```
153+
154+
When prompted for HTTPS redirction, select **Option 2**, forcing HTTPS traffic.
155+
156+
:::
157+
158+
<br>
159+
160+
Experiment by **[Matthew Reichardt](https://github.com/matthewjamesr)**

src/learn/mvc.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ cd my-app
5454
php leaf serve
5555
```
5656

57-
Your app is now running! Open [http://localhost:5500](http://localhost:5500) in your browser.
57+
Your app is now running! Open <a href="http://localhost:5500" target="_blank" rel="noreferrer">http://localhost:5500</a> in your browser.
5858

5959
## Project Structure
6060

@@ -257,7 +257,7 @@ You can use the `withFlash()` method to send a message to the next request. This
257257

258258
### <span class="bg-[var(--vp-c-bg-alt)] h-6 inline-flex items-center justify-center rounded-full text-gray-700 dark:text-gray-300 text-lg w-6 mr-1 flex-none font-normal">5</span> Deploying your app
259259

260-
We have built a simple pre-launch page using Leaf MVC. You can now deploy your app to a server using a service like [Heroku](/learn/deployment/heroku), [Fly.io](/learn/deployment/flyio) a VPS like [DigitalOcean](/learn/deployment/digitalocean), or even a shared hosting service like [Sevalla](/learn/deployment/sevalla).
260+
We have built a simple pre-launch page using Leaf MVC. You can now deploy your app to a server using a service like [Heroku](/learn/deployment/heroku/), [Fly.io](/learn/deployment/flyio/) a VPS like [DigitalOcean](/learn/deployment/digitalocean/), or even a shared hosting service like [Sevalla](/learn/deployment/sevalla/).
261261

262262
<div class="my-4 md:my-10">
263263
<div

0 commit comments

Comments
 (0)