Download the PHP package codemystify/wordforge without Composer

On this page you can find all versions of the php package codemystify/wordforge. 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 wordforge

WordForge

A Laravel-inspired routing system for WordPress REST API with PHP 8 compatibility.

Features

Usage

Basic Routes

Route Groups

Resource Routes

Named Routes

Parameter Conversion

WordForge automatically converts Laravel-style route parameters to WordPress REST API compatible format:

Laravel Format WordPress Format
posts/{id} posts/(?P<id>[0-9]+)
posts/{slug} posts/(?P<slug>[a-z0-9-]+)
posts/{postId} posts/(?P<post_id>[0-9]+)
posts/{year}/{month?} posts/(?P<year>[0-9]{4})(/(?P<month>[0-9]{1,2}))?

Middleware

Installation

Requirements

CI Status License: MIT PHP Version

WordForge is a simple, opinionated SLIM MVC framework for WordPress that brings structure to plugin development. While WordPress is a powerful platform, plugins often become unwieldy and disorganized as they grow in complexity. WordForge addresses this problem by providing a clear architectural pattern inspired by Laravel, but with zero third-party dependencies.

Table of Contents

Why WordForge?

WordPress plugin development often lacks structure. As plugins grow, code becomes scattered across files with no clear organization. WordForge addresses this problem by providing:

Features

Installation

You can install the package via composer:

Getting Started

Basic Setup

After installing the package, you need to initialize WordForge in your plugin with just one line:

That's it! The framework will:

  1. Automatically detect if it's running from a vendor directory
  2. Load configuration from your plugin's config directory
  3. Register service providers from your config
  4. Load routes from your routes directory
  5. Handle asset URLs, views, and more

Creating Routes

Create a routes/api.php file in your plugin directory:

Important: Using Route Facade vs. Router Class

Always use the Route facade rather than the Router class directly in your route definitions:

Troubleshooting Routes

If your routes aren't working after registering your plugin and service provider:

  1. Check Namespace Configuration: Make sure your API namespace is properly set in your config:

  2. Route Service Provider: Ensure your RouteServiceProvider is properly registered and sets the namespace before routes are loaded:

  3. Bootstrap Timing: Bootstrap WordForge early in your plugin:

  4. Debug Mode: To diagnose route issues, enable WordPress debug mode:

  5. Access Routes: Routes are available at:

Route Parameter Constraints

WordForge provides a Laravel-inspired way to define route parameter constraints using the where method. When building WordPress REST API endpoints, you should use proper regex patterns to constrain your route parameters for security and validation.

Common Regex Patterns for Route Parameters

While WordPress REST API normally requires complex regex syntax, WordForge simplifies this to be more Laravel-like. Here are the recommended patterns to use with the where method:

WordPress vs WordForge Pattern Syntax

WordForge simplifies WordPress's complex regex parameter handling:

  1. WordPress REST API requires patterns in the format: '(?P<parameter_name>pattern)'
  2. WordForge uses a Laravel-inspired syntax: ->where('parameter_name', 'pattern')

Behind the scenes, WordForge transforms your simple constraints into the complex WordPress format, making your routes more readable and maintainable.

Default Parameter Patterns

WordForge provides sensible defaults for common parameter names:

Best Practices

For consistency and security, we recommend following these patterns:

Using these patterns helps ensure your routes work correctly and securely with both WordForge and the WordPress REST API.

Creating Controllers

Create a controller in your plugin:

Form Request Validation

Create a form request for validation:

And use it in your controller:

Using the Query Builder

WordForge includes a powerful query builder inspired by Laravel's Eloquent:

Available Query Methods

The query builder provides many methods for constructing queries:

Middleware

Create middleware to filter requests:

Register middleware in your routes:

Helper Functions

WordForge provides several helper functions to simplify common tasks:

Advanced Usage

Service Providers

Service providers in WordForge are now even more powerful with hook-based initialization:

Register the service provider in your config file:

Service Management

WordForge includes a lightweight service manager for managing dependencies:

Creating Custom Validation Rules

Create a custom validation rule:

Use the custom rule in a form request:

Working with Views

Create view files in your plugin's views directory:

Render views in your controller:

Assets and URLs

Generate URLs to assets in your plugin:

Configuration Management

Create configuration files in your plugin's config directory:

Access configuration values:

Project Structure

Here's a recommended project structure for a WordForge-based plugin:

Philosophy

WordForge is built on several key principles:

  1. Structure Over Convention: WordPress often relies on loosely structured code. WordForge provides clear patterns for organizing your code.

  2. Simplicity First: The framework intentionally avoids complex features and dependencies. It's designed to be easy to understand and modify.

  3. WordPress Native: While bringing Laravel-inspired patterns, WordForge remains true to WordPress at its core, working with WordPress hooks and APIs rather than against them.

  4. Build Only What You Need: The framework provides a foundation, but you're encouraged to extend only the parts you need for your specific project.

  5. No Magic: WordForge avoids "magical" behaviors that hide implementation details. The code is straightforward and traceable.

Limitations

WordForge is intentionally lightweight and doesn't try to solve every problem:

Testing

WordForge includes a testing setup that makes it easier to test your plugin:

  1. Set up PHPUnit in your plugin:

  2. Create a PHPUnit configuration file:

  3. Create a bootstrap file for your tests:

  4. Write your tests:

  5. Run your tests:

License

The MIT License (MIT). Please see License File for more information.

Credits


All versions of wordforge with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
ext-json Version *
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 codemystify/wordforge contains the following files

Loading the files please wait ...