PHP code example of larablocks / highway
1. Go to this page and download the library: Download larablocks/highway 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/ */
larablocks / highway example snippets
Larablocks\Highway\HighwayServiceProvider::class,
'Highway' => Larablocks\Highway\Highway::class,
Highway::
Highway::addReader($type, $config_options[])
$configs = [
'file_path' => 'path_to_csv_file')] // aults to ','
'enclosure' => 'enclosure string')] // optional, defaults to '"'
]
Highway::addReader('csv', $configs)
$configs = [
'table' => 'table_to_read_from')] // / optional else returns all results from table Ex. 'results' => DB::table('users')->where('first_name', 'John')->get()
]
Highway::addReader('database', $configs)
Highway::addWriter($type, $config_options[])
$configs = [
'file_path' => 'path_to_csv_file')] // aults to ','
'enclosure' => 'enclosure string')] // optional, defaults to '"'
]
Highway::addWriter('csv', $configs)
$configs = [
'table' => 'table_to_write_to')] //
Highway::run()
Highway::addReader('database', ['table' => 'users', 'results' => DB::table('users')->where('first_name', 'Devin')->get()]);
Highway::addWriter('csv', ['file_path' => public_path('export/users.csv')]);
Highway::run();
Highway::addReader('database', ['table' => 'users']);
Highway::addWriter('csv', ['file_path' => public_path('export/users.csv')]);
Highway::addWriter('csv', ['file_path' => public_path('export/users-tab-delimited.csv'), 'delimiter' => "\t", 'enclosure' => "'"]);
Highway::run();