PHP code example of samybgt / screenwidth

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

    

samybgt / screenwidth example snippets



return [
  'devices' => [
    'mobile' => [
      'min' => 0,
      'max' => 576
    ],
    'tablet' => [
      'min' => 576,
      'max' => 992
    ],
    'desktop' => [
      'min' => 992,
      'max' => 10000
    ],
  ],
  'auto_reload' => true,
  'exceptUrls' => [
    
  ],
];

config/samybgt/screenwidth.php

resources/views/vendor/samybgt/screenwidth/screenwidth_loader.blade.php

screenwidth

app/Providers/RouteServiceProvider.php

Route::middleware(['web','screenwidth'])
                ->namespace($this->namespace)
                ->group(base_path('routes/web.php'));

Route::group(['prefix' => '', 'middleware' => ['your_middleware_1','screenwidth']], function()
{
  Route::get('/route_1', 'AppController@method1');
  Route::get('/', 'AppController@landing');
});

@screenwidth_reportWindowSize

@

// To get the width of the client screen.

screenwidth_get()
// Output: 1234

// To get the device type based on width and breakpoints given in config file

screenwidth_device()
// Output: desktop

// Check if the device is that type based on parameter and config file

screenwidth_is('desktop')
// Output: true / false