PHP code example of fx / platform

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

    

fx / platform example snippets


// routes/web.php
use Fx\Platform\Facades\Platform;

// others ...

// 多平台路由组
Platform::route(function () {
	Route::get('test', 'HomeController@test');
});


// App\Providers\AppServiceProvider

use Fx\Platform\Facades\Platform;
use App\Repositories\Contacts\UserRepository;
use App\Repositories\Admin\UserRepository as DefaultUserRepository;

public function register() 
{
	// others ...

	// UserRepository
	Platform::register(UserRepository::class, DefaultUserRepository::class);
	// Or
	// Platform::registerGroup([UserRepository::class => DefaultUserRepository::class]);
}


// App\Http\Controllers\HomeController
use App\Repositories\Contacts\UserRepository;

public function test(UserRepository $user)
{
	// do somethings with $user
	// eg: $users = $user->get();
}
bash
php artisan platform:init