level51/silverstripe-find-http-action

Finds actions by HTTP method used on the request.

Maintainers

Package info

github.com/Level51/silverstripe-find-http-action

Homepage

Issues

Type:silverstripe-vendormodule

pkg:composer/level51/silverstripe-find-http-action

Statistics

Installs: 1 539

Dependents: 0

Suggesters: 0

Stars: 0

0.2.0 2019-11-13 16:08 UTC

This package is auto-updated.

Last update: 2026-03-01 00:13:31 UTC


README

License Version

Trait for finding controller actions by HTTP method used on the request. Handy for building CRUD based Webservices. Can be used alongside the default action handling.

Requirements

  • Silverstripe 4.x

Installation

  • composer require level51/silverstripe-find-http-action
  • Flush config (flush=all)

Usage

use Level51\FindHTTPAction\FindHTTPAction;
use SilverStripe\Control\Controller;

class MyCRUDController extends Controller {

    use FindHTTPAction;

    ...
    
    private static $url_handlers = [
        'foo/$id'  => [
            'GET'    => 'getFooRecords',
            'POST'   => 'createFooRecord',
            'PUT'    => 'updateFooRecord',
            'DELETE' => 'deleteFooRecord'
        ],
        'bar/$id!' => [
            'PUT' => 'updateBarRecord'
        ],
        'about'    => 'myRegularAction
    ];
}

Maintainer