You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/docs/index.md
+64-5Lines changed: 64 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,14 @@
1
1
# Hello there 👋
2
2
3
-
Leaf is a slim and lightweight PHP framework focused on developer experience, usability, and high-performance code. It is a modern PHP framework built to be simple and elegant, yet extremely powerful.
Leaf is a slim and lightweight PHP framework focused on developer experience, usability, and high-performance code. It is a modern PHP framework built to be simple and elegant, yet extremely powerful.
11
+
11
12
```php
12
13
<?php
13
14
@@ -22,12 +23,70 @@ app()->run();
22
23
23
24
Writing code should be simple and fun, and that's what Leaf is all about.
24
25
25
-
Leaf is built to be modular, so you can use only what you need. There's no need to learn a whole new framework to use Leaf, just familiarize yourself with the core concepts and you're good to go. This makes Leaf a great choice for both beginners and experienced developers.
26
+
## Why Leaf?
26
27
27
-
Ready to get started? Check out the [installation guide](/docs/installation) to get Leaf up and running in no time. You can also check out the [interactive tutorial](/tutorial/) to learn more about Leaf's core concepts and features.
28
+
PHP frameworks often come with a steep learning curve, performance overhead, and strict conventions, which can complicate maintenance and limit flexibility amongst other issues like bloat. Leaf addresses these challenges by offering a range of features designed to make web development easier and more enjoyable:
29
+
30
+
- Leaf is beginner-friendly, enabling PHP newcomers to build powerful apps within minutes. All you need is basic PHP knowledge and, optionally, some backend web dev familiarity.
31
+
32
+
- Leaf is lightweight and blazing fast with a minimal core and a load of optional modules for building full apps and APIs efficiently, offering high performance and low memory usage.
33
+
34
+
- Leaf is built to enhance developer focus, offering features like class-free initializers and global functions for easy access to classes across your app, creating an optimized PHP developer experience.
35
+
36
+
- Leaf is designed for seamless integration with other libraries and frameworks, prioritizing simplicity over complex setups like providers needed by other frameworks.
37
+
38
+
- Leaf is highly scalable, and grows with your project. Its core and ecosystem of libraries make it ideal for projects of any size.
39
+
40
+
<!-- Leaf is built to be modular, so you can use only what you need. There's no need to learn a whole new framework to use Leaf, just familiarize yourself with the core concepts and you're good to go. This makes Leaf a great choice for both beginners and experienced developers. -->
41
+
42
+
## How to Use These Docs
43
+
44
+
On the left side of the screen, you'll find the docs navbar. The pages of the docs are organized sequentially, from basic to advanced, so you can follow them step-by-step when building your application. However, you can read them in any order or skip to the pages that apply to your use case.
45
+
46
+
On the right side of the screen, you'll see a table of contents that makes it easier to navigate between sections of a page. If you need to quickly find a page, you can use the search bar at the top, or the search shortcut (Ctrl+K or Cmd+K).
47
+
48
+
To get started, check out the [Installation guide](/docs/installation).
49
+
50
+
## Pre-Requisite Knowledge
51
+
52
+
Although our docs are designed to be beginner-friendly, we need to establish a baseline so that the docs can stay focused on Leaf's functionality. We assume you have a basic understanding of PHP and it's syntax, as well as a little familiarity with web development concepts like HTTP, routing, and middleware.
53
+
54
+
Don't worry if you're not familiar with these concepts, we'll provide videos and links to relevant documentation whenever we introduce a new concept like the one below:
55
+
56
+
<VideoModal
57
+
buttonText="PHP Tutorial for Beginners"
58
+
description="This video is a PHP tutorial for beginners. It covers the basics of PHP and is a great starting point for anyone new to the language."
Leaf is built with many classes and components, but for simpler apps or APIs, it also offers a functional mode. This lets you use Leaf and its modules without class imports, instantiation, or lengthy namespaces—keeping things simple and streamlined.
65
+
66
+
Of course, you can still use Leaf in class mode if you prefer that. Here's an example of a simple Leaf app in functional mode:
67
+
68
+
```php
69
+
<?php
70
+
71
+
use Leaf\App;
72
+
73
+
require __DIR__ . '/vendor/autoload.php';
74
+
75
+
$app = new App;
76
+
77
+
$app->get('/', function () use ($app) {
78
+
$app->response()->json(['message' => 'Leaf is amazing!']);
79
+
});
80
+
81
+
$app->run();
82
+
```
83
+
84
+
The documentation will usually show you how to use modules in functional mode as this is the default mode for Leaf. However, if you are migrating from another framework or you prefer to use Leaf in class mode, you can always instantiate the classes and use them as you would in any other framework.
28
85
29
86
## Getting Started
30
87
88
+
Ready to get started? Check out the [installation guide](/docs/installation) to get Leaf up and running in no time. You can also check out the [interactive tutorial](/tutorial/) to learn more about Leaf's core concepts and features.
Leaf is built by design to be incrementally adoptable. This means that it can be integrated into a project multiple ways depending on the requirements. You can use Leaf on its own which is generally recommended for small/medium sized projects, or you can use it with an additional structure like [Leaf MVC](/docs/mvc/) for more complex applications.
10
10
11
-
1.[Use the Leaf CLI to scaffold a project [RECOMMENDED]](#leaf-cli).
12
-
2.[Download leaf through composer](#composer)
13
-
3.[Scaffold a Leaf MVC project](#mvc-setup)
14
-
15
11
## Technical Requirements
16
12
17
13
Before you create your first Leaf application, you need to make sure you meet the following requirements:
@@ -23,54 +19,53 @@ Before you create your first Leaf application, you need to make sure you meet th
23
19
24
20
::: details Not sure where to start?
25
21
26
-
-Laravel released an amazing tool called [Laravel Herd](https://herd.laravel.com/) that provides a quick and easy way to set up a local PHP development environment for Mac. It's a great way to get started with PHP and Leaf.
22
+
-Beyond Code released an amazing tool called [Laravel Herd](https://herd.laravel.com/) that provides a quick and easy way to set up a local PHP development environment for Mac and Windows. It's a great way to get started with PHP if you don't have it installed yet.
27
23
28
-
-On Windows, Linux and Mac, you can use [Xampp](https://www.apachefriends.org/), which is a free and open-source cross-platform web server solution stack package developed by Apache Friends, consisting mainly of the Apache HTTP Server, MariaDB database, and interpreters for scripts written in the PHP and Perl programming languages.
24
+
-Another way to install PHP and Composer without any hassle is to use [php.new](https://php.new/) which was created by Beyond Code. It's a quick way to get started on Windows, Linux and Mac with just one command.
29
25
30
-
:::
26
+
- A more traditional way on Windows, Linux and Mac, you can use [Xampp](https://www.apachefriends.org/), which is a free and open-source cross-platform web server solution stack package developed by Apache Friends, consisting mainly of the Apache HTTP Server, MariaDB database, and interpreters for scripts written in the PHP and Perl programming languages.
31
27
32
-
## Leaf CLI
28
+
Once you have PHP and Composer installed, you can proceed with the installation of Leaf CLI.
Leaf provides an [official CLI](https://github.com/leafsphp/cli) for quickly creating and managing your Leaf applications. It takes just a few seconds to get up and running with your leaf app. See [the Leaf CLI docs](/docs/cli/) for more details.
32
+
## Automatic Installation
40
33
41
-
Using the CLI, you can quickly scaffold a new Leaf project with:
34
+
We recommend starting a new Leaf app using the Leaf CLI, which sets up everything automatically for you. To create a project, run:
42
35
43
36
```bash:no-line-numbers
44
37
leaf create <project-name>
45
38
```
46
39
47
-
The CLI also allows you to completely customize the installation you wish to create. You can choose different features like database, authentication, etc. This is done using the `--custom` flag:
40
+
This command will walk you through a quick setup process where you can choose the features you want in your app. There are more options available in the CLI, which you can find in the [CLI documentation](/docs/cli/).
48
41
49
-
```bash:no-line-numbers
50
-
leaf create <project-name> --custom
51
-
```
52
-
53
-
You can then run your app using the `serve` command:
42
+
Once your project is generated, you can run it using the `serve` command:
Leaf also allows a more traditional approach to installation. You can install leaf through composer. You can use this method if you don't want to use the leaf cli or if you want to use leaf as a dependency in your project. The disadvantage of this method is that you don't get a quick-start setup like you do with the leaf cli.
62
+
Leaf also allows a more traditional approach to installationthrough [composer](https://getcomposer.org/). We recommend using the Leaf CLI since it provides a more streamlined setup process, but of course, you can use composer if you prefer. The disadvantage of this method is that you don't get a quick-start setup like you do with the leaf cli.
68
63
69
64
```bash:no-line-numbers
70
65
composer require leafs/leaf
71
66
```
72
67
73
-
After insalling Leaf, you need to create your index.php file which will be the entry point to your application.
68
+
After installing Leaf, you need to create your index.php file which will be the entry point to your application.
74
69
75
70
::: code-group
76
71
@@ -103,7 +98,3 @@ $app->run();
103
98
:::
104
99
105
100
When hosting your application on a webserver, all requests coming into your app must be routed through Leaf. It is really simple to do, and all needed instructions can be found @ [URL rewriting](/docs/routing/url-rewriting).
106
-
107
-
## MVC Setup
108
-
109
-
Leaf is built to be modular, so you can use only what you need. Unfortunately, this means that a simple Leaf app does not give you any structure to work with. You can structure your app however you want, but if you're building a complex application, you might want to consider using Leaf MVC. Leaf MVC is a full but ridiculously light-weight MVC framework that creates an MVC skeleton for you to work with. It is still Leaf, but with a more structured approach. To get started, you can check out the [MVC docs](/docs/mvc/).
Copy file name to clipboardExpand all lines: src/docs/routing/index.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
<!-- markdownlint-disable no-inline-html -->
4
4
5
-
Leaf comes with a powerful router that allows you to define routes for your application. The router is responsible for determining which route should be called and rendering the appropriate view or response. You can take it as one fancy traffic officer that directs traffic to the right place.
5
+
Routing is the foundation of every web application. It's the process of defining the URL structure of your application and how it responds to requests. Leaf comes with a powerful router that simplifies the way you define routes in your application. You can take routing as one fancy traffic officer that directs traffic to the right place.
Copy file name to clipboardExpand all lines: src/docs/utils/testing.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -92,7 +92,9 @@ composer run alchemy # Run all of the above
92
92
93
93
## Configuring Tests
94
94
95
-
If you don't want to use Pest, Alchemy also supports PHPUnit. You can change the testing framework by editing the `alchemy.yml` file in your project root, add your tests to the `tests` directory, and run the test command again. You don't need to worry about setting up PHPUnit or Pest as Alchemy will handle that for you.
95
+
Alchemy uses Pest for testing by default. Pest is a delightful PHP Testing Framework with a focus on simplicity which matches Leaf's philosophy. We are working on adding support for PHPUnit as well.
96
+
97
+
<!-- If you don't want to use Pest, Alchemy also supports PHPUnit. You can change the testing framework by editing the `alchemy.yml` file in your project root, add your tests to the `tests` directory, and run the test command again. You don't need to worry about setting up PHPUnit or Pest as Alchemy will handle that for you. -->
96
98
97
99
By default Pest expects a `phpunit.xml` file in your project root, but as it's quite annoying to read, Leaf provides a `alchemy.yml` file in your project root. This file is used to configure Pest and is much easier to read and understand. The `alchemy.yml` file is used to configure Pest and can be used to set up your test environment.
98
100
@@ -115,7 +117,7 @@ tests:
115
117
116
118
- `app`: This is a list of directories that contain your application code. Alchemy will use these directories to lint your code and also in code coverage reports. If you want to use the root directory, you can just remove the entire `app` section.
117
119
118
-
- `tests.engine`: The testing engine to use. Only Pest and PHPUnit are supported engine at the moment, but we plan to add support for other engines in the future.
120
+
- `tests.engine`: The testing engine to use. Only Pest is supported engine at the moment, but we plan to add support for other engines in the future.
119
121
120
122
- `tests.parallel`: Whether to run tests in parallel. This can speed up your test suite significantly.
0 commit comments