PHP code example of thee-prime / wpflint-app
1. Go to this page and download the library: Download thee-prime/wpflint-app library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
thee-prime / wpflint-app example snippets
use MyShop\Http\Controllers\OrderController;
// Logged-in users only:
$router->ajax( 'my-shop/save-order', [ OrderController::class, 'store' ] )
->middleware( [ 'nonce:my_shop_save_order', 'can:edit_posts' ] );
// Public endpoint (guests + logged-in):
$router->ajax( 'my-shop/get-prices', [ OrderController::class, 'prices' ] )
->nopriv();
use MyShop\Http\Controllers\OrderController;
$router->rest( 'my-shop/v1', function ( $r ) {
$r->get( '/orders', [ OrderController::class, 'index' ] );
$r->post( '/orders', [ OrderController::class, 'store' ] );
$r->get( '/orders/(?P<id>\d+)', [ OrderController::class, 'show' ] );
$r->put( '/orders/(?P<id>\d+)', [ OrderController::class, 'update' ] );
$r->delete( '/orders/(?P<id>\d+)', [ OrderController::class, 'destroy' ] );
} );
AdminPage::make( __( 'My Shop', 'my-shop' ), 'my-shop' )
->icon( 'dashicons-cart' )
->position( 56 )
->render( function () { ettings.php';
} )
->register();
use MyShop\Jobs\ExampleJob;
wpflint_dispatch( new ExampleJob( $user_id ) );
// Delayed (runs after 60 s):
wpflint_dispatch( ( new ExampleJob( $user_id ) )->delay( 60 ) );
// Different queue, max 5 attempts:
wpflint_dispatch( ( new ExampleJob( $user_id ) )->on_queue( 'emails' )->tries( 5 ) );
my-shop-plugin/
├── app/
│ ├── Http/
│ │ ├── Controllers/
│ │ ├── Middleware/
│ │ └── Requests/
│ ├── Events/
│ ├── Jobs/
│ │ └── ExampleJob.php
│ ├── Listeners/
│ ├── Models/
│ ├── Providers/
│ │ └── AppServiceProvider.php ← start here
│ └── Rules/
├── config/
│ └── app.php
├── database/
│ └── migrations/
├── routes/
│ ├── ajax.php ← wp_ajax_* actions
│ └── api.php ← REST API endpoints
├── templates/
├── vendor-prefixed/ ← Strauss output (namespace-isolated framework)
├── my-shop.php ← main plugin file
└── uninstall.php