php console serve
http://127.0.0.1:8000approutes/web.phproute::get('/','mainController@index')->name('home');
/ и вызываем метод index в контроллере mainController, так же даём имя маршруту home в цепочке методов ->name()route::get('/',function() {
//Тут мы что то выполняем например можем показать какой то вид View('home')
return View('home');
})->name('home');
route::get('/catalog/item/{id}',functio... mainController.php шаблон есть в файле def.phpindex()public function index() {
//Тут мы что то выполняем например можем показать какой то вид View('home')
return View('home');
}
request или хелперrequest()request()->route('id');
route::get('/catalog/item/{id}',function($id) {
//В переменной $id будет первая переменная из маршрута
request()->input('name'); home.phpView('home',['message'=>'hello','message2'=>'world']);
<?php ?> так и компилируемые с помощью спецсимволов {{Переменная или функция}} или @функция<h1>Hello World!!!</h1>
<strong>yes {{$message}} {{$message2}}!</strong>
Time: {{date('H:i:s')}}
lay - папка, html - файл@extends('lay.html')
@section('content')
<div>Контент</div>
@endsection
@section('head','Текст')
@yield('content')
@php
$var = 123;
@endphp
<ul>
@foreach($items as $item)
<li>{{$item}}</li>
@endforeach
</ul>
appService.php в методе register или же подключить свой класс через appServiceимя функции,анонимная функция(агрументы переданные в функцию,последним всегда будет анонимная функция для добавления в конец буффера))compiler::declare('plus',function($arg1,$arg2,$appendFnc){
$appendFnc('<?php echo '.$arg1.'; ?>');
return "<?php echo ".($arg1+$arg2)."; ?>";
});
@plus(2,4)
62<link href="{{compressor(['css/style.css', 'css/style2.css'], 'styles.css')}}" rel="stylesheet">
text/javascript или text/css можем указать своё в 3 агрументе функцииdb.php шаблон есть в файле def.php$tableprotected $table='other_table';
public function index() {
$this->model("db");
...
controller::model("db");
имя модели:$db = $this->model()->db;
controller::model("db")->find(1)->delete()
$db->select('name')->where('id',1)->first();
$db->select('name','test','status')->where('uid',1)->get();
$db->name = 'name';
$db->price = '123';
$db->save();
find() используется для получения записи по ID):$db->find(1);
$db->name = 'name2';
$db->price = '1234';
$db->save();
$db->find(1);
$db->delete(); storage::disk('local')->put('file.txt','какие то данные');
storage::disk('local')->get('file.txt');
storage::disk('local')->delete('file.txt');
storage::disk('local')->exists('file.txt');
...
<input type="file" name="file" />
<input type="text" name="fileName" value="default"/>
...
request()->file('file')->storeAs('',request()->input('fileName').'.jpg'); ключ,данные,время хранения в секундах)cache::put('message','Hello World!',60);
cache::get('message');
cache::pull('message');
cache::forget('message');
cache::has('message'); $response = http::get('http://url');
$response->body(); //Тело ответа
$response->json(); //Если запрашивали json можно сразу преобразовать в массив
$response->header('имя заголовка'); //Получить заголовок из ответа
$response->headers(); //Получить все заголовки в виде массива
$response->ok(); //Если всё хорошо то true
$response->successful(); //Если код от 200 до 299
$response->failed(); //Если код от 400 до 499
$response->clientError(); //Если код 400
$response->serverError(); //Если код 500
http::post('http://url',['name'=>'value']);
application/jsonapplication/x-www-form-urlencoded то добавьте метод asForm перед выполнением запросаhttp::asForm()->post('http://url',['name'=>'value']);
multipart/form-datahttp::asMultipart()->post('http://url',['name'=>'value']);
http::withBasicAuth('user', 'password')->get('http://url');
http::withDigestAuth('user', 'password')->get('http://url');
http::withDigestAuth('user', 'password')->withRealm('realm')->get('http://url');
http::timeout('20')->get('http://url');
http::post('http://url',['name'=>'value'])->throw();
http::post('http://url',['name'=>'value'])->throw(function($response, $error){
die("ой, что-то пошло не так");
}); exceptions::declare('имя_исключения',function($data=""){
return response('что то сломалось '.$data);
});
exceptions::throw('имя_исключения', 'Обновите страницу');
abort('имя_исключения');
exceptions::declare('validate',function($errors){
return response()->json([
'status'=>false,
'errors'=>$errors
]);
}); .env...
# Logs
LOG_ENABLED=true
...
ROOT/storage/.log/log::info('Какой то вывод');
errorlog::error('Ошибка');
thisLine в этом случае информация не запишется в файл а будет перезаписываться на этой же строке в консолеlog::thisLine(true)->info(date('s')); php console serve
php console cache:clear
route/console.php создаём маршрут с методом console с замыканиемroute::console('time',function(){
while(true) { //Создаём вечный цикл
log::thisLine(true)->info(date('H:i:s')); //Выводим текущее время и смещаем каретку в начало
sleep(1); //Ставим задержку на выполнение в 1 секунду
}
});
php console time
route::console('hello:{arg1}',function($arg1){
log::info('Hello '.$arg1);
//или
log::info('Hello '.request()->route('arg1'));
...
php console hello:world