Download the PHP package danc0/gimliduck-php without Composer

On this page you can find all versions of the php package danc0/gimliduck-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package gimliduck-php

GimliDuck ⚔️🦆

An adaptable micro PHP framework that tries to stay out of your way.

Very much a work in progress, use at your own risk...

Certainty of death. Small chance of success. What are we waiting for?

Installation

composer require danc0/gimliduck-php

Create a skeleton project with: composer create-project danc0/gimli-skeleton

Add the devtools with composer require --dev danc0/gimliduck-devtools

Create a .htaccess file that looks something like this to point requests to your index.php file

Usage

Creating a GimliDuck application is simple:

That is really all you need to get started. You can add more like a template engine, a config file, etc, but you don't have to.

A more complex example

The Application class also registers the basic Event handler and Session class when it is created. Additionally, if your config includes enable_latte the Latte template engine will be added to the Application instance using the config value for template_base_dir as the template directory.

Declaring Routes

By default Gimli will require any files in the App/Routes directory. You can disable this by setting autoload_routes to false in your config file. You can change the directory by setting the value of route_directory in your config file. You can also load additional route files with the following method:

There are a few things you can do with your route callbacks... pass a string, a callable, or an array.

Any of those work, it's up to you how you do it.

You can add middleware if you need some extra defense

That should be a class that implements Gimli\Middleware\Middleware_Interface which requires a process method that returns Gimli\Middleware\Middleware_Response. Middleware does have access to the Application instance including the Injector and whatever else you decide to set on it.

You can also add groups, define a default route file that should load, and load additional route files to help organize your routes.

Your routes can also contain variable arguments that meet the following patterns:

You will need to add their variable name using the # symbol in the route definition.

This variable name is passed to the router and set as a dependency for your controller method. You should use the defined variable name as an argument in your controller method. The value will be typecast based on the available types to settype, possible types:

Example controller method:

Controllers should return a Gimli\Http\Response object. There are helper methods that return formatted Response objects to help limit some conditional logic:

Job files are also given the following arguments subcommand, options, and flags. The options argument is an array of arrays containing the name and value. The flags argument is an array with the given flags. The subcommand argument is just a string if a subcommand was given.

Dependency Injection

You can use the built in Injector to bind or register dependencies. You can also resolve dependencies from the Injector. You can add anything you need to the Injector and access it throughout your application through the Application instance.

The built in Injector will autowire classes and resolve dependencies as needed. You can also bind a class to a closure if you need to do some setup before returning the class or register an already created object. The example below shows a single action controller that would be resolved from the Router class. The __construct method parameters are resolved from the Injector.

The method parameters are also resolved by the Injector when the Route dispatches the method.

There are also Injector helper methods that cut down on some inline code. Typically if you wanted to inject a class inline you could do it with $this->Application->Injector->resolve(Some_Class::class) or Application::get()->Injector->resolve(Some_Class::class). The methods resolve and resolve_fresh are available to cut on that inline code.

Database

There is a basic PDO wrapper Database as well as a Pdo_Manager class you can use to manage database queries. The Pdo_Manager class returns and instance of PDO and can be used to run queries directly. The Database class is a wrapper around the Pdo_Manager class and provides some basic query methods. There is also a very basic Model base class and additional helper methods for Database, like elsewhere these methods handle the dependency injection and call the methods on the injected Database class. The helpers are:

Model Seeders

There is a basic seeder class that can be used to seed your database. This relies on attributes placed in the model classes to instruct the Seeder how to create the data.

You can then seed the database with the following code:

Instead of create you can call getSeededData to get the data that would be inserted into the database. This is useful for testing or manually loading a Model without saving it. You can also pass a callback method that will be given the data of the initial Model. This helps to seed related data. The callback should return an array of Seeder instances.

The passed seed ensures the data remains the same each time that seeder is run, resulting in reproducible datasets. The Seeder class has a getRandomSeed method that will return a random seed value. This is useful for creating random data that you don't need to be reproducible, or to generate a random seed you can copy and use.

Config Helpers

There are also a few Config helpers:


All versions of gimliduck-php with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
latte/latte Version >=3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package danc0/gimliduck-php contains the following files

Loading the files please wait ....