Code Monkey home page Code Monkey logo

leafapi's Introduction





Leaf API 3

Latest Stable Version Total Downloads License

Leaf API is a lightweight but feature-rich MVC framework built on top of leaf php. It provides everything you need to build APIs with Leaf, faster and simpler than ever before.

📦 Installation

You can install Leaf API v3 with the Leaf CLI

leaf create <project-name> --api

Or for a more personalized installation, you can add --custom to the command

leaf create <project-name> --api --custom

You can also use Composer if you don't want to use the Leaf CLI, although we recommend using the CLI for a better experience:

composer create-project leafs/api <project-name>

Note that <project-name> is the name of the project you want to create, and that will be your folder name. You can also use . to install in the current directory.

🗂 Directory Structure

```bash
C:.
├───app
│   ├───console
│   ├───controllers
│   ├───database
│   │   ├───factories
│   │   ├───migrations
│   │   ├───schema
│   │   └───seeds
│   ├───helpers
│   ├───models
│   ├───routes
│   └───views
├───config
├───lib
├───public
│   └───assets
├───storage
│   ├───app
│   │   └───public
│   ├───framework
│   │   └───views
│   └───logs
└───vendor

This directory structure is a blend of Ruby on Rails and Laravel

To run your Leaf API application, use

php leaf serve

📓 Learning Leaf API

  • Leaf API has a very easy to understand documentation which contains information on all operations in Leaf API.

  • Since Leaf API runs on Leaf, you should check out the Leaf PHP Framework documentation here.

  • You can also check out our youtube channel which has video tutorials on different topics

  • We are also working on codelabs which will bring hands-on tutorials you can follow and contribute to.

😇 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.

We will furthermore like to thank our existing supporters, we love you all ❤️

💬 Stay In Touch

🎨 Links/Projects

leafapi's People

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

Watchers

 avatar  avatar  avatar  avatar  avatar

leafapi's Issues

Can't create a model with attributes

Hi, I'm using leaf to an personal proyect, and I discover that if I have a $fillable attribute on a model I can't create one passing that parameter.

Genre::create(['description' => 'Genre test 1']);
//description isn't populate

thansk!

PS: Sorry if my english isn't good

Auto docs of api

Hi Mychi, and thank you first of all For your wonderful work!

I'd like to use your LeafAPI, but i have one question: does it implements some auto doc like swagger of similar?

Also, can you provide an example with some models, authorization, permission? This is the tipical need of a rest api, and it would be really useful For anybody that want to use leafAPI..
Thank you!
Mauro

.env does not loading.

Hello, I'm trying to make "Your first Leaf API" in doc.

I faced a error in "Using our model" section.

public function index() { $this->respond(Post::all()); }
Fatal error:
Uncaught InvalidArgu Fatal error: Uncaught InvalidArgumentException: Unsupported driver [] in /demo/vendor/illuminate/database/Connectors/ConnectionFactory.php:285 Stack trace: #0 /demo/vendor/illuminate/database/Connectors/ConnectionFactory.php(76): Illuminate\Database\Connectors\ConnectionFactory->createConnection(false, Object(Closure), false, '', Array) #1 /demo/vendor/illuminate/database/Connectors/ConnectionFactory.php(50): Illuminate\Database\Connectors\ConnectionFactory->createSingleConnection(Array) #2 /demo/vendor/illuminate/database/DatabaseManager.php(131): Illuminate\Database\Connectors\ConnectionFactory->make(Array, 'default') #3 /demo/vendor/illuminate/database/DatabaseManager.php(86): Illuminate\Database\DatabaseManager->makeConnection('default') #4 /demo/vendor/illuminate/database/Eloquent/Model.php(1257): Illuminate\Database\DatabaseManager->connection('defaul in /demo/vendor/illuminate/database/Connectors/ConnectionFactory.php on line 285

It looks like .env does not loading.

So I put
\Dotenv\Dotenv::create(__DIR__)->load();
in index.php just after
require_once __DIR__ . '/vendor/autoload.php';
Is this right way to fix this error?

Parse error

Hi on windows running on php 7.3.1 I have an error:

Parse error: syntax error, unexpected '' (T_NS_SEPARATOR), expecting function (T_FUNCTION) or const (T_CONST) in \leaf\api\vendor\leafs\leaf\src\App.php on line 21

Regards.
g.

Connection refused with db port other than 3306

Hi, my local mysql database is on a port other than 3306 (on Mamp Pro is 8889), setting the port on the .env file to 8889 the connection is refused. I tried to change the MySql port to 3306 and in this case the connection works correctly. I don't understand why DB_HOST, DB_DATABASE, DB_USERNAME and DB_PASSWORD are correctly retrieved, while DB_PORT (and probably all environment variables that enter the pdoOptions array) are not retrieved from the .env file.

Maybe I'm missing something or is it a bug?
I am using Leaf version 3 with Db version 2

The environment variable of the DB_PORT is null, as if it were not set, in that case it tries to connect to port 3306 by default, returning this error:

PDOException thrown with message "SQLSTATE[HY000] [2002] Connection refused"

Stacktrace:
#9 PDOException in /vendor/leafs/db/src/Db/Core.php:134
#8 PDO:__construct in /vendor/leafs/db/src/Db/Core.php:134
#7 Leaf\Db\Core:connect in /vendor/leafs/auth/src/Auth/Core.php:79
#6 Leaf\Auth\Core:connect in /vendor/leafs/auth/src/Auth/Core.php:91
#5 Leaf\Auth\Core:autoConnect in /app/controllers/Controller.php:20
#4 App\Controllers\Controller:__construct in /vendor/leafs/router/src/Router/Core.php:458
#3 Leaf\Router\Core:invoke in /vendor/leafs/router/src/Router/Core.php:424
#2 Leaf\Router\Core:handle in /vendor/leafs/router/src/Router/Core.php:356
#1 Leaf\Router\Core:run in /public/index.php:130
#0 require_once in /index.php:24

Thanks

API pagination responses

Hi! How i can implements an paginator of responses with Leaf API? For example using LIMIT and OFFSET mysql statetments

Thanks...

error migrating files

hello, please this is my first time using this framework and i am having issues with my first migration, below is a screenshot of the error.
Screenshot (29)

below is my composer.json file
Screenshot (30)

Response code not working

Hi :-)
I would like to ask you about response code. When I am using respondWithCode with any argument except 200 then my response still have 200.
I tried go another way and set code manually (setCode(401))

Code in json message is ok.

Am I doing something wrong?
Thank you

Migrations fail

(Duplicate Issue from leafsphp/leaf#54)

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 leafsphp/leaf@0ca6097
Maybe a dependency conflict?

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.