PHP code example of vtapp / vtphp

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

    

vtapp / vtphp example snippets


$router->resource('/posts', 'App\Controller\PostController');

$router->apiResource('/posts', 'App\Controller\Api\PostController');

$users = User::all();

// Filter and transform
$activeUsers = $users
    ->where('status', 'active')
    ->sortBy('name')
    ->pluck('email');

// Map data
$userNames = collect($users)->map(function($user) {
    return strtoupper($user->name);
});

// Group by attribute
$byRole = $users->groupBy('role');

class PackageServiceProvider extends ServiceProvider
{
    public function register()
    {
        $this->app->bind('package', function() {
            return new Package(env('PACKAGE_KEY'));
        });
    }
}

'providers' => [
    App\Providers\PackageServiceProvider::class,
],

<!-- layouts/app.php -->
<!DOCTYPE html>
<html>
<head>
    <title>@yield('title')</title>
</head>
<body>
    @yield('content')
</body>
</html>

<!-- home.php -->
@extends('layouts.app')

@section('title', 'Home Page')

@section('content')
    <h1>Welcome!</h1>

    @component('components.card')
        @slot('title')
            Featured Content
        @endslot

        This is the card body.
    @endcomponent
@endsection
bash
php artisan migrate
bash
php artisan serve
bash
php artisan make:model Post --migration
bash
php artisan make:controller PostController --resource
bash
php artisan make:provider PackageServiceProvider