Giter Site home page Giter Site logo

leafsphp / leaf Goto Github PK

View Code? Open in Web Editor NEW
1.0K 27.0 59.0 953 KB

🍁 The easiest way to create clean, simple but powerful web apps and APIs quickly

Home Page: https://leafphp.dev

License: MIT License

PHP 100.00%
php php-framework leaf leafphp php-micro-framework framework framework-php mvc api rest-framework

leaf's Introduction




Leaf 3

Latest Stable Version Total Downloads License



Leaf is a PHP framework that helps you create clean, simple but powerful web apps and APIs quickly and easily. Leaf introduces a cleaner and much simpler structure to the PHP language while maintaining it's flexibility. With a simple structure and a shallow learning curve, it's an excellent way to rapidly build powerful and high performant web apps and APIs.

🗂 Basic Usage

This is a "hello world" application created using Leaf. After installing Leaf, create an index.php file.

<?php

require __DIR__ . '/vendor/autoload.php';

app()->get('/', function () {
  response()->json([
    'message' => 'Welcome!'
  ]);
});

app()->run();

You may quickly test this using the Leaf CLI:

leaf serve

Or with the built-in PHP server:

php -S localhost:8000

🍁 Why Leaf?

When it comes to building web applications, there are numerous tools and frameworks at your disposal. Nevertheless, we are convinced that Leaf is the optimal selection for developing powerful, web applications and APIs.

The problems

While PHP frameworks can make web development faster and more efficient, there are some potential challenges or drawbacks to using them, including:

  • Learning curve: Most PHP frameworks have a steep learning curve, especially for developers who are new to the language or the framework's conventions.
  • Performance overhead: Some PHP frameworks can add unnecessary performance overhead, due to the additional abstraction layers and features they provide.
  • Code maintenance: Most frameworks require adhering to specific coding standards and conventions, which can make maintenance and updates more challenging if you are not already familiar with those standards.
  • Limited flexibility: PHP frameworks can be more rigid than writing code from scratch, as they may require you to adhere to specific coding standards and conventions. This can limit your flexibility in terms of how you structure your code and handle specific use cases.
  • Compatibility with other systems: Most PHP frameworks are bound to a particular ecosystem and make it difficult to randomly pick and use packages which don't have support for the framework you are using.
  • Packing a ton of unused code/packages: Just about every PHP framework out there adds a ton of complexity to your applications in the form of unused code, classes and packages. This in turn leads to bloat and ultimately a drop in performance

How Leaf tackles these

Leaf 3 provides a bunch of features that aim to tackle these common problems found in just about every PHP framework out there.

  • Low barrier to entry

    Leaf is the easiest framework to learn with PHP newbies building powerful leaf apps in a few minutes of reading the docs/watching out tutorial videos. All you truly need to get started with Leaf is basic PHP knowledge and optional but recommended knowledge on some backend concepts like JWT auth and more.

  • Lightweight

    Leaf 2 was lightweight and fast enough to be considered one of the most lightweight but powerful frameworks around, and Leaf 3 makes leaf 2 look like a joke. Leaf 3 can now be considered the most lightweight PHP framework with a source of about 30kb and allows you to build full apps and APIs which end up less than 20mb including user dependencies (leaf api). This is a big haul compared to other frameworks that require dependencies and tons of files which end up more than 200mb.

    image

    a comparison with slim - slim (left) - leaf (right)

  • Enables high developer productivity

    A whole lot of research and testing has been done to build amazing features which allow developers to focus on only what they need: their apps. Leaf 3 has put tons of strategies together to create the best developer experience known to PHP. From things like removing class initializers and creating global functions which allow you call classes from anywhere in your application, modules and other amazing leaf features.

  • Powered by modules

    Leaf 3 and its ecosystem are heavily powered by modules, which are simply pieces of leaf's functionality shipped into independently installable libraries. Modules help make leaf even more lightweight and help developers only deal with features which they need in their applications. This means that you only install what you need.

  • Easy to use features

    As mentioned above, a lot of research has gone into the developer experience for leaf 3 and one aspect was to make our existing features more performant and easier to use. We employed various strategies like modeling some features after popular libraries in other languages and frameworks. For instance, the API for leaf cors is almost an exact replica of the expressjs cors middleware.

  • Library/Framework compatibility

    Since the beginning of Leaf, we've set out to create code which could easily be integrated with other libraries and frameworks. No matter how powerful leaf is, we try to base of everything we do on simple concepts as opposed to other frameworks which need things like providers in order to access framework features in libraries.

  • Scalability

    One of the most beautiful things about leaf is that, no matter what package you're using with leaf, if it works in development, it will definitely work in production with near zero config, unless you want some special features. Leaf provides a core and other frameworks/libraries that build around leaf. This makes leaf appropriate for almost any project no matter it's size.

📦 Installation

You can create a Leaf 3 app with the Leaf CLI

leaf create <project-name> --basic

<project-name> is the name of your project

You can also use Composer to install Leaf 3 in your project quickly.

composer require leafs/leaf

✈️ The Leaf Ecosystem (Libs & Frameworks)

Project Status Description
leaf Latest Stable Version Total Downloads Create websites and APIs quickly
leafmvc Latest Stable Version Total Downloads An MVC wrapper for leaf (for general development)
leafapi Latest Stable Version Total Downloads An MVC wrapper for leaf geared towards API development
skeleton Latest Stable Version Total Downloads Leaf boilerplate for rapid development
leaf-ui Latest Stable Version Total Downloads A PHP library for building user interfaces
cli Latest Stable Version Total Downloads CLI for creating & interacting with your leaf apps

🧩 The Leaf Ecosystem (Modules)

Project Status Description
alchemy Latest Stable Version Total Downloads A test runner for your Leaf apps
aloe Latest Stable Version Total Downloads Smart console helper for leaf mvc, leaf api and skeleton
anchor Latest Stable Version Total Downloads Basic security tools
auth Latest Stable Version Total Downloads Simple but powerful authentication system for your apps
bareui Latest Stable Version Total Downloads Dead simple templating engine with no compilation (blazing speed)
blade Latest Stable Version Total Downloads Laravel blade templating port for leaf
cookie Latest Stable Version Total Downloads Cookie management without the tears
cors Latest Stable Version Total Downloads CORS operations made simple
csrf Latest Stable Version Total Downloads Basic CSRF protection
date Latest Stable Version Total Downloads PHP dates for humans
devtools Latest Stable Version Total Downloads Devtools for your Leaf app
db Latest Stable Version Total Downloads Leaf Db from v2 (actively maintained)
db-old Latest Stable Version Total Downloads Leaf Db from v1 (still maintained)
exception Latest Stable Version Total Downloads Leaf's exception wrapper (fork of whoops)
experiments Latest Stable Version Total Downloads collection of experimental modules
fetch Latest Stable Version Total Downloads HTTP requests made simple
form Latest Stable Version Total Downloads Form processes and validation
fs Latest Stable Version Total Downloads Awesome filesystem operations + file uploads
http Latest Stable Version Total Downloads Http operations made simple (request, response, ...)
logger Latest Stable Version Total Downloads leaf logger module
mail Latest Stable Version Total Downloads Mailing made easy with leaf
mvc-core Latest Stable Version Total Downloads Core MVC tools powering our MVC wrappers
password Latest Stable Version Total Downloads Password encryption/validation/hashing in one box
redis Latest Stable Version Total Downloads Redis module
router Latest Stable Version Total Downloads Default router for leaf php
session Latest Stable Version Total Downloads PHP sessions made simple
tilly Latest Stable Version Total Downloads Simple utility 'toolkit' for PHP applications
veins Latest Stable Version Total Downloads Leaf veins templating engine
viewi Latest Stable Version Total Downloads Leaf integration with Viewi PHP

💬 Stay In Touch

📓 Learning Leaf 3

  • Leaf has a very easy to understand documentation which contains information on all operations in Leaf.
  • You can also check out our youtube channel which has video tutorials on different topics
  • You can also learn from codelabs and contribute as well.

😇 Contributing

We are glad to have you. All contributions are welcome! To get started, familiarize yourself with our contribution guide and you'll be ready to make your first pull request 🚀.

To report a security vulnerability, you can reach out to @mychidarko or @leafphp on twitter. We will coordinate the fix and eventually commit the solution in this project.

🤩 Sponsoring Leaf

Your cash contributions go a long way to help us make Leaf even better for you. You can sponsor Leaf and any of our packages on open collective or check the contribution page for a list of ways to contribute.

And to all our existing cash/code contributors, we love you all ❤️

🤯 Links/Projects

leaf's People

Contributors

awilum avatar brutalhost avatar ftonato avatar herber avatar jeijei4 avatar joanhey avatar kristories avatar monkeywithacupcake avatar mychidarko avatar pablouser1 avatar pjotrsavitski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

leaf's Issues

_env not working on CLI

Describe the bug

The helper function _env() relies on $_ENV validation, preventing the correct use on CLI

To Reproduce
Steps to reproduce the behavior:

  1. Run the application using injected environments variables (like in docker and docker-compose and kubernetes) and skip the use of .env file (using .env files in clusters and containers is bad practice)
  2. debug the content of the container (docker) executing the command printenv to verify the variable you want has been injected in the container.
  3. Dump the content using the PHP function getenv() from inside leaf PHP (cli), The variable injected should be there, cool!
  4. Do the same but with _env()... Hmm, the variable is not there!

Expected behavior
_env() should read the environment variables just like getenv does.

Additional context
I love the simplicity and flexibility of this framework.

What I'm doing is basically running the leaf framework inside a docker container to execute a command (not web), and because is docker, the .env files won't be used to handle environment variables, instead all the variables are injected to the container just like it works with any other framework.

Unfortunately the presence of $_ENV in the validation inside _env function prevent the use of the variable even though the variable was captured by the official PHP function getenv().

Negative images

Hello leaf,

This is soo cool. It is simple and light.
I loved it.
But I think the negative image on the Landing page is a BAD user experience.

Thanks

Unable to start using application

After fresh installation via composer leaf is not working. Using example code:

<?php

require __DIR__ . "/vendor/autoload.php";

app()->get("/", function () {
  response()->json(["message" => "Hello World!"]);
});

app()->run();

Getting:

PHP Fatal error: Uncaught Error: Call to undefined function app()

Paths are correct. Application just does not work. Using latest version: 3.0 RC2.

P.S. Does the phpmailer should exist by default in 'vendor' directory if I did not install 'mail' module?

Create a standard for functional mode

Functional mode is new to leaf core but has been present in leaf mvc, leaf API and skeleton. This comes along with a ton of inconsistencies that need to be resolved.

Fatal error: Uncaught InvalidArgumentException: Unsupported driver

I am a Chinese user, can not speak English, or a PHP rookie, this is using Google automatic translation, I apologize first. I encountered an error using the model, What did I do wrong?

Fatal error: Uncaught InvalidArgumentException: Unsupported driver

My program code:

App\Controllers\UserController.php

namespace App\Controllers;

use Leaf\Controller;
use App\Models\User;

class UsersController extends Controller
{
    public function index()
    {
        $users = User::all();
        foreach ($users as $user) {
            echo $user->name;
        }
    }

App\Models\User.php

namespace App\Models;

use Leaf\Model;

class User extends Model
{
    protected $table = 'users';
    public $timestamps = false;
}

My database connection:

$db = new Leaf\Db("localhost", "root", "root", "demo");

Follow standards

Is your feature request related to a problem? Please describe.
Follow standards

Describe the solution you'd like

  • PHP-CS fixer setup for maintaining coding styles and standard
  • Github workflow for PHP-CS fixer
  • Refactoring code

Describe alternatives you've considered
🙅🏼

References

Additional context
🙅🏼

Optimise Leaf\App

Leaf\App is bloated due to a lot of repetitive code matching what is written in leaf router.

Db choose undefined on version 2.1.0

I am getting PHP Fatal error: Uncaught Error: Call to undefined method Leaf\Db::choose() after updating to 2.1.0 using

$leaf = new Leaf\App();
$leaf->db->connect($dbHost, $dbUser, $dbPassword, $dbDatabase);

I had to do this to fix it

$leaf = new Leaf\App();
$db = new Db\Mysqli();
$leaf->db = $db;
$leaf->db->connect($dbHost, $dbUser, $dbPassword, $dbDatabase);

Method to set charset in MySQLi

I have added the following method to accept accents in file Mysqli.php

/**
 * Set the charset to use
 * 
 * @param string $charset: Charset
 */
public function charset(String $charset = 'utf8') {
	$this->connection->set_charset($charset);
}

Sorry, don't know how to pull request at the moment

Optional patterns: empty first parameter

When calling this route:

$app->get('/messages/(\d+)(/\d+)?', function ($id, $date = 0) use($app) {
    $app->response->respond($id);
});

with /messages/2 the output/$id is empty. When calling it with /messages/2/34 it will correctly output 2.

Same happens with the blog route from the example: https://leafphp.netlify.app/#/2.1/routing/sub-patterns. When I add year output like this:

$leaf->get('/blog(/\d+)?(/\d+)?(/\d+)?(/[a-z0-9_-]+)?', function($year = null, $month = null, $day = null, $slug = null) {
  if (!$year) { echo "Blog overview $year"; return; }
  if (!$month) { echo "Blog year overview $year"; return; }
  if (!$day) { echo 'Blog month overview'; return; }
  if (!$slug) { echo 'Blog day overview'; return; }
  echo 'Blogpost ' . htmlentities($slug) . ' detail';
});

it will be empty when calling it with one number only.

Is there a way to get the get the first parameter?

Auth - register

Hi,

I did the registration through authorization and I get this error message.

Can you help me with that?

POST:
{ "username": "admin", "email": "[email protected]", "password": "s" }

Error:
{ "error": { "dev": "Call to a member function bind_param() on bool" }, "code": 500 }

Code:

$app->post('/register', function () use ($app, $form, $auth) {
        $username = $app->request()->get("username");
        $email = $app->request()->get("email");
        $password = $app->request()->get("password");

        $validation = $form->validate([
            "username" => "username",
            "email" => "email",
            "password" => "required"
        ]);

        if (!$validation) $app->response()->throwErr($form->errors());


        $user = $auth->register("users", [
            "username" => $username,
            "email" => $email,
            "password" => $password
        ]);

        if (!$user) $app->response()->throwErr($auth->errors());
        $app->response()->json($user);
    });

Break leaf auth into subclasses

Not every part of leaf auth is used in every single app people build. This means there'll be unused code that adds up to the load time of apps. This can be separated into subclasses which can be called on demand.

Leaf Request error when sending json object as data

It seems that Leaf Request doesn't handle json object as data.
For example, with this payload:
{ name: toto age: 20 address: { name: 'my road' number: 18 town: 'Paris' } }

I get this fatal error:
Uncaught ErrorException: htmlspecialchars() expects parameter 1 to be string, array given in C:\wamp64\www\api.mecadrive\Leaf\Http\Request.php on line 242

Is there any way to access these values with someting like:
$request->get('address')->get('town'); // Paris
or

$request->get('address');
$request['town']; // Paris

Thank's for the job !

Cannot use object of type Leaf\Exceptions\FrameCollection as array

Describe the bug
An error occurs when generating an error:
Cannot use object as array in /vendor/leafs/exception/src/Exceptions/Inspector.php:219.

https://github.com/leafsphp/exceptions/blob/9f9728a7cbd01c1a51697dc8272a621856436f6b/src/Exceptions/Inspector.php#L219

To Reproduce

<?php

// Undefined variable $var2.
$var1 = count($var2);

image

Expected behavior
I was expecting the following error:
image

Additional context
I temporarily fixed it like this, but it needs review and testing:

<?php

219   if ( 0 < $newFrames->count() ) {
220       $newFrames->offsetGet( 0 )->addComment(
221           $previousInspector->getExceptionMessage(),
222           'Exception message:'
223       );
224   }

LogWriter class prepending lines

The Leaf\LogWriter class is prepending log lines, with double line breaks, which is unusual.

file /vendor/leafs/logger/src/LogWriter.php, lines 50-53:

        FS::prepend(
            $this->logFile,
            (string) "[" . Date::now() . "]\n" . $level . "$message\n"
        );

I would suggest to change to the linux standard:

        FS::append(
            $this->logFile,
            (string) "[" . Date::now() . "] " . $level . "$message"
        );

Current log file:

[2022-09-14 22:31:03]
DEBUG - Array
(
    [message] => Congrats!! You're on Leaf API
)


[2022-09-14 22:31:03]
INFO - is it working?????


Suggested log file:

[2022-09-14 22:41:29] INFO - is it working????? because now it's 2022-09-14 10:41:29
[2022-09-14 22:39:26] INFO - is it working????? because now it's 2022-09-14 10:39:26
[2022-09-14 22:39:12] INFO - is it working????? because now it's 2022-09-14 10:39:12
[2022-09-14 22:38:44] DEBUG - Array([message] => Congrats!! You're on Leaf API)
[2022-09-14 22:38:44] INFO - is it working????? because now it's 2022-09-14 10:38:44
[2022-09-14 22:31:03] INFO - is it working?????
[2022-09-14 19:53:50] INFO - is it working?????
[2022-09-14 22:42:13] INFO - is it working????? because now it's 2022-09-14 10:42:13

Easy to read and we can watch log using "tail -f log.log" linux command...

Malformed JWT

Describe the bug
I just found out that there is a problem with the deformed JWT.
The JWT library throws an error that must be caught.

I found a problem in Authentication.php: 116 (version 2.X)
You can fix it as follows.

try {
$payload = JWT::decode ($ token, $ secretPhrase, ['HS256']);
if ($ payload! == null) return $ payload;
} catch (\ DomainException $ exception) {
self :: $ errorsArray ["token"] = "Malformed token";
}

Thank you so much :-)

To Reproduce
Steps to reproduce the behavior:

  1. Send malformed JWT

Expected behavior
40x response

Response from GET Request Return as Null

Hi there,

We're following the main tutorial to obtain the GET parameter from the URL and output it to a JSON response.

$app->get("/user", function() use($app) {

  $name = $app->request()->get("name");
  $app->response()->json([
    "name" => $name,
    "day" => "test"
  ]);

});

Expected response should be like this:
curl -X GET http://localhost/user?name=test

{
    "name": test,
    "day": "test"
}

But it keeps throwing out null as the response.

{
    "name": null,
    "day": "test"
}

More information: php-7.4.16 / nginx 1.18.0

Thank you.

Migrations fail

Hy there. I can't get Migrations running with LeafAPI. It always breaks with error on line 14 (var capsule is invalid).
php leaf db:install worked and the database was created successfully.
php leaf db:migrate fails.

leaf_db_migrate_error_capsule

Can you help me with this? Thanks a lot!

Versions, i'm using:

  • PHP 8
  • Leaf 2.6.0
  • Aloe 1.1.0

Edit//
It seems to be related to last commit 0ca6097
Maybe a dependency conflict?

Support of sqlite3 in LeafDB

Hello,

It's not a bug it's a feature request.

Do you plan to add the support of sqlite3 un LeafDB ?

Have a nice day.

Multiple instances?

Can i have multiple instance of leaf in different dirs?

/
L api/ <- leaf instance 1
  L v1/
  L v2/
L admin-api/ <- leaf instance 2
  L v1/

Using custom request and response objects

Is your feature request related to a problem? Please describe.
In some case, you would like to add custom methods to the request or response objects. The easiest use case for this would be custom authentication where you would want to attach a user method to the request object.

Describe the solution you'd like
A solution that lets users extend the current request and response classes and add to them.

$app->response->respond in index.php:13 does not work

$app->response->respond does not exist.
Fatal error: Uncaught Error: Call to undefined method Leaf\Http\Response::respond()

I tried to help by creating the respond($data) function in Respond.php but it wouldn't work.

Please be kind, as I'm still figuring stuff out.

response()->status(400)

Not sure if it's a bug.
According to the documentation:

Status #

Info

You can directly set status codes on responses, there's no need to use this method unless you want to use PHP's output methods like echo

The HTTP response returned to the client will have a status code indicating the response’s type (e.g. 200 OK, 400 Bad Request, or 500 Server Error). You can use the Leaf application’s response object to set the HTTP response’s status like this:

response()->status(400);
You only need to set the response object’s status if you intend to return an HTTP response that does not have a 200 OK status. >You can just as easily fetch the response object’s current HTTP status by invoking the same method without an argument, like this:

$status = response()->status();

If I put the following code:

app()->get("/", function () {
    echo response()->status(400);
});

It will display in browser

HTTP/1.1 200 OK

Not the expected

HTTP/1.1 400 BAD REQUEST

Composer Doesn't Load

v1.5.0

Fatal error: Uncaught Error: Class 'Leaf\Core\Leaf' not found in /var/www/html/portal/index.php:58 Stack trace: #0 {main} thrown in /var/www/html/portal/index.php on line 58

$leaf = new Leaf\Core\Leaf;

All other composer packages in vendors are working fine.

debug = false not worked as expected

If you try to disable debug mode to not show code or more details on-screen when you got an error 500, the .env

APP_DEBUG=false

or instruction

app()->config('debug',false)

will not prevent the nice debug screen to show up.

Screen Shot 2022-09-26 at 2 18 30 PM

Is Leaf tested?

Hello!

Thanks for your work.

My colleagues and I are willing to give Leaf a try. However I cannot see any tests. Is the framework tested in some ways?

Database connection wrong documentation

Hey guys, great framework. I just start to using it and must say, it is great job!

The documentation using db module is wrong.

$db->connect('127.0.0.1', 'username', 'password', 'dbname');

Need to be:

$db->connect('127.0.0.1', 'dbname', 'username', 'password');

The other things working just fine, I'm testing and building my app on this.

Thanks!

\Leaf\Util::sanitize null values

Hello,

I have start a new project with the last leaf.php version.
Very nice growing seed.

I had a problem with the sanitize function, used to get values from http request body.
Getting the null value is very useful I think

Do you think this fix can cause any issues ?
\Leaf\Util::sanitize
L.22 $data = is_null($data) ? null : htmlspecialchars($data, ENT_QUOTES, 'UTF-8');

Thank you
Best regards

Get started with simple Hello World

I simply has installed Leaf by Composer and trying to run Hello World code, but:

Fatal error: Uncaught Error: Class 'PhpOption\Option' not found in /Users/camilo/Projects/vocabulagro/backend/vendor/illuminate/support/Env.php:100 Stack trace:
#0 /Users/camilo/Projects/vocabulagro/backend/vendor/illuminate/support/helpers.php(265): Illuminate\Support\Env::get('APP_DOWN', NULL)
#1 /Users/camilo/Projects/vocabulagro/backend/vendor/leafs/leaf/src/App.php(1263): env('APP_DOWN')
#2 /Users/camilo/Projects/vocabulagro/backend/index.php(13): Leaf\App->run()
#3 {main} thrown in /Users/camilo/Projects/vocabulagro/backend/vendor/illuminate/support/Env.php on line 100

Any help?

Nested mounts example

How do they work? I keep getting ArgumentCountError Too few arguments to function {closure}(), 0 passed and exactly 1 expected

$leaf->mount('/user', function() use ($leaf, $response, $twig) {

    $leaf->get('/', function() use($response) {
        echo $response->renderMarkup('<p>no user id</p>');
    });

    // will result in '/movies/id'
    $leaf->mount('/(\d+)', function($id) use ($leaf, $response, $twig) {

        echo $response->renderMarkup("<p>user {htmlentities($id)}</p>");

        $leaf->get('/', function() use($response) {
            //do something
        });

    });

});

Error Database Connection

[Thu Oct 17 10:33:34 2019] PHP Warning: Module 'exif' already loaded in Unknown on line 0
[Thu Oct 17 10:33:34 2019] PHP Warning: Module 'mbstring' already loaded in Unknown on line 0
[Thu Oct 17 10:33:34 2019] PHP Warning: Module 'pgsql' already loaded in Unknown on line 0
PHP 7.2.19-0ubuntu0.18.04.2 Development Server started at Thu Oct 17 10:33:34 2019
Listening on http://localhost:8000
Document root is /home/andyawuku/Documents/leaf-php-boilerplate
Press Ctrl-C to quit.
[Thu Oct 17 10:33:45 2019] PHP Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /home/andyawuku/Documents/leaf-php-boilerplate/src/config/db.php:5
Stack trace:
#0 /home/andyawuku/Documents/leaf-php-boilerplate/src/config/init.php(10): Database->connectMysqli('localhost', 'root', '', 'books')
#1 /home/andyawuku/Documents/leaf-php-boilerplate/index.php(26): require('/home/andyawuku...')
#2 {main}
thrown in /home/andyawuku/Documents/leaf-php-boilerplate/src/config/db.php on line 5
[Thu Oct 17 10:33:45 2019] 127.0.0.1:33392 [500]: / - Uncaught Error: Call to undefined function mysqli_connect() in /home/andyawuku/Documents/leaf-php-boilerplate/src/config/db.php:5
Stack trace:
#0 /home/andyawuku/Documents/leaf-php-boilerplate/src/config/init.php(10): Database->connectMysqli('localhost', 'root', '', 'books')
#1 /home/andyawuku/Documents/leaf-php-boilerplate/index.php(26): require('/home/andyawuku...')
#2 {main}
thrown in /home/andyawuku/Documents/leaf-php-boilerplate/src/config/db.php on line 5
[Thu Oct 17 10:33:48 2019] PHP Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /home/andyawuku/Documents/leaf-php-boilerplate/src/config/db.php:5
Stack trace:
#0 /home/andyawuku/Documents/leaf-php-boilerplate/src/config/init.php(10): Database->connectMysqli('localhost', 'root', '', 'books')
#1 /home/andyawuku/Documents/leaf-php-boilerplate/index.php(26): require('/home/andyawuku...')
#2 {main}
thrown in /home/andyawuku/Documents/leaf-php-boilerplate/src/config/db.php on line 5
[Thu Oct 17 10:33:48 2019] 127.0.0.1:33396 [500]: / - Uncaught Error: Call to undefined function mysqli_connect() in /home/andyawuku/Documents/leaf-php-boilerplate/src/config/db.php:5
Stack trace:
#0 /home/andyawuku/Documents/leaf-php-boilerplate/src/config/init.php(10): Database->connectMysqli('localhost', 'root', '', 'books')
#1 /home/andyawuku/Documents/leaf-php-boilerplate/index.php(26): require('/home/andyawuku...')
#2 {main}
thrown in /home/andyawuku/Documents/leaf-php-boilerplate/src/config/db.php on line 5

Fresh API install not working

Installed locally Leaf 3.
Created a new API project.
Run leaf serv.
The default json code do not show up:

Screen Shot 2022-09-14 at 1 24 50 PM

Code:

Screen Shot 2022-09-14 at 1 22 52 PM

Using PHP 8.1:

Screen Shot 2022-09-14 at 1 25 54 PM

But if I change line 3-5 to

app()->get("/", function () {
    response()->json(["message" => "Congrats!! You're on Leaf API"]);
});

It works:

Screen Shot 2022-09-14 at 1 27 17 PM

Could not find any restrictions to PHP 8.1, if any.

PHP 8 Support?

When Leaf PHP support php 8?

  [InvalidArgumentException]
  Package leafs/cli has a PHP requirement incompatible with your PHP version,
   PHP extensions and Composer version

Logger not working

Describe the bug
Looks like the logger is not working, followed the instructions in the doc.

To Reproduce
Just by adding this line, to test the logger :
app()->logger()->info('Hello');

Expected behavior
It should create and write the log file (it is enabled and well defined in config/app.php, I'm using the core template v3), and yes
"leafs/logger" is installed via composer.

Additional context
The error :
`
Error thrown with message "Cannot use object of type Leaf\Helpers\Container as array"

Stacktrace:
#10 Error in /app/vendor/leafs/leaf/src/App.php:168
#9 Leaf\App:Leaf{closure} in /app/vendor/leafs/leaf/src/Helpers/Container.php:223
#8 Leaf\Helpers\Container:Leaf\Helpers{closure} in /app/vendor/leafs/leaf/src/Helpers/Container.php:67
#7 Leaf\Helpers\Container:get in /app/vendor/leafs/leaf/src/App.php:210
#6 Leaf\App:__get in /app/vendor/leafs/leaf/src/App.php:292
#5 Leaf\App:logger in /app/app/controllers/BrainController.php:25
#4 App\Controllers\BrainController:facial in /app/vendor/leafs/router/src/Router/Core.php:489
#3 call_user_func_array in /app/vendor/leafs/router/src/Router/Core.php:489
#2 Leaf\Router\Core:invoke in /app/vendor/leafs/router/src/Router/Core.php:455
#1 Leaf\Router\Core:handle in /app/vendor/leafs/router/src/Router/Core.php:386
#0 Leaf\Router\Core:run in /app/public/index.php:130
`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.