PHP code example of codebjorn / mjolnir

1. Go to this page and download the library: Download codebjorn/mjolnir 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/ */

    

codebjorn / mjolnir example snippets

 php
\Mjolnir\Admin\Option::get('someOption');
\Mjolnir\Admin\Option::update('someOption', 'someContent');
 php
\Mjolnir\Admin\Page::dashboard('Page', 'Page', 'read', 'page');
\Mjolnir\Admin\Page::management('Page', 'Page', 'read', 'page');
 php
$books = \Mjolnir\Content\PostType::make('Books')
    ->supports(['title', 'editor'])
    ->public(true)
    ->showInRest(true);

$books->register(); //Call register to exit creating of arguments
 php
$countries = \Mjolnir\Content\Taxonomy::make('Countries')
    ->postTypes(['books'])
    ->public(true)
    ->showInRest(true);

$countries->register(); //Call register to exit creating of arguments
 php
\Mjolnir\Content\Shortcode::add('hello', [$this, 'hello']);
\Mjolnir\Content\Shortcode::do('[hello]');
 php
\Mjolnir\Routing\Api::make('/namespace', '/users')
    ->get([$this, 'getUsers'], '_return_true')
    ->post([$this, 'postUsers'], [$this, 'isAdmin']);
 php
$first = \Mjolnir\Support\Arr::first($array);
$key = \Mjolnir\Support\Arr::get($array, 'key');
 php
$collection = \Mjolnir\Support\Collection::make($array);
$filtered = $collection->where('key', 'value');
$reversed = $filtered->reverse();
 php
\Mjolnir\Support\Is::file($value);
\Mjolnir\Support\Is::str($value);
\Mjolnir\Support\Is::int($value);
 php
$string = \Mjolnir\Support\Str::make('some string');
$reversed = $string->flip();
$contains = $string->has('some');
 php
\Mjolnir\Utils\Enqueue::style('theme-style', 'folder/style.css', [], '1.0.0', 'all');
\Mjolnir\Utils\Enqueue::script('theme-script', 'folder/script.css', [], '1.0.0', true);
\Mjolnir\Utils\Enqueue::all();
 php
$currentPost = \Mjolnir\Utils\Post::current();
$post = \Mjolnir\Utils\Post::get(1);
$postId = $post->getId();
$postSlug = $post->getSlug();
 php
{{Namespace}}\Facades\Action::do('hook');
{{Namespace}}\Facades\Action::add('hook', [$this, 'function']);
{{Namespace}}\Facades\Action::group('hook')
    ->add([$this, 'function'])
    ->add(SomeClass::class)
    ->add(function () {
        echo "something todo";
    });
 php
{{Namespace}}\Facades\Filter::apply('filter');
{{Namespace}}\Facades\Filter::add('filter', [$this, 'function']);
{{Namespace}}\Facades\Filter::group('filter')
    ->add([$this, 'function'])
    ->add(SomeClass::class)
    ->add(function () {
        echo "something todo";
    });
 php
{{Namespace}}\Facades\Config::get('configFile.index.anotherIndex');
{{Namespace}}\Facades\Config::get('app.view.folder');
 php
{{Namespace}}\Facades\View::render('books.single');
{{Namespace}}\Facades\View::render('books/single.blade.php');