PHP code example of servabofidem / laravel-vuforia

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

    

servabofidem / laravel-vuforia example snippets


'providers' => [
    ...
    Panoscape\Vuforia\VuforiaWebServiceProvider::class,
];

'aliases' => [
    ...
    'VWS' => Panoscape\Vuforia\Facades\VuforiaWebService::class,
];

VWS::addTarget([
    'name' => 'my_new_target', 
    'width' => 320, 
    'path' => public_path('storage/IMG_2738.jpg')
    ]); 

 VWS::addTarget(['name' => '123 1']);

VWS::addTarget(['name' => '123']);

VWS::addTarget(['name' => '1231', 'width' => 100, 'path' => public_path('storage/image.png')]);

$target = new \Panoscape\Vuforia\Target;
$target->name = 'image_01'; 
$target->width = 320; 
$target->image = file_get_contents(public_path('images/001.jpg')); 
//optional fields
$target->metadata = 'Hello world'; 
$target->active = false; 

[
    "status" => 201,
    "body" => '{"result_code":"TargetCreated","transaction_id":"xxx","target_id":"xxx"}',
]

[
    "status" => 422,
    "body" => '{"result_code":"BadImage","transaction_id":"xxx"}',
]  

[
    /*
    |--------------------------------------------------------------
    | Vuforia Web Service URLs
    |--------------------------------------------------------------
    |
    |
    */
    'url' => [
        /*
        |--------------------------------------------------------------
        | Vuforia Web Service Targets Request URL
        |--------------------------------------------------------------
        |
        |
        */
        'targets' => 'https://vws.vuforia.com/targets',

        /*
        |--------------------------------------------------------------
        | Vuforia Web Service Duplicates Request URL
        |--------------------------------------------------------------
        |
        |
        */
        'duplicates' => 'https://vws.vuforia.com/duplicates',

        /*
        |--------------------------------------------------------------
        | Vuforia Web Service Summary Request URL
        |--------------------------------------------------------------
        |
        |
        */
        'summary' => 'https://vws.vuforia.com/summary',
        ],

    /*
    |--------------------------------------------------------------
    | Vuforia cloud database credentials
    |--------------------------------------------------------------
    |
    |
    */
    'credentials' => [
        /*
        |--------------------------------------------------------------
        | Vuforia cloud database access key
        |--------------------------------------------------------------
        |
        |
        */
        "access_key" => env('VUFORIA_ACCESS_KEY'),

        /*
        |--------------------------------------------------------------
        | Vuforia cloud database secret key
        |--------------------------------------------------------------
        |
        |
        */
        "secret_key" => env('VUFORIA_SECRET_KEY'),
    ],

    /*
    |--------------------------------------------------------------
    | Max image size(unencoded) in Byte. Default is 2MB
    | Set to null to bypass size checking(not recommended)
    |--------------------------------------------------------------
    |
    |
    */
    'max_image_size' => 2097152,

    /*
    |--------------------------------------------------------------
    | Max metadata size(unencoded) in Byte. Default is 2MB
    | Set to null to bypass size checking(not recommended)
    |--------------------------------------------------------------
    |
    |
    */
    'max_meta_size' => 2097152,

    /*
    |--------------------------------------------------------------
    | Name checking rule. Default is 
    | no spaces and may only contain: 
    | numbers (0-9), letters (a-z), underscores ( _ ) and dashes ( - )
    | Set to null to bypass name checking(not recommended)
    |--------------------------------------------------------------
    |
    |
    */
    'naming_rule' => '/^[\w\-]+$/'
]

/**
* Upload image to Vuforia
*/
abstract class VuforiaJob implements ShouldQueue
{
    use InteractsWithQueue, Queueable, SerializesModels;
    
    /**
    * Execute the job.
    *
    * @param  VuforiaWebService  $vws
    * @return void
    */
    abstract function handle(VuforiaWebService $vws);
    
    /**
    * The job failed to process.
    *
    * @param  Exception  $exception
    * @return void
    */
    abstract function failed(Exception $exception);
}

abstract class VuforiaNotification extends Notification
{
    use Queueable;

    protected $result;

    /**
     * Create a new notification instance.
     *
     * @param mixed $result
     *
     * @return void
     */
    public function __construct($result)
    {
        $this->result = $result;
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return ['database'];
    }

    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toArray($notifiable)
    {
        return [
            'result' => $this->result
        ];
    }
}