//... app()->get('/', function () { response()->json(['msg' => 'műkszik']); });
HTTP kliensbe:
app()->get('/msg', function() { response()->json(['msg' => 'üdv']); });
HTTP kliensbe:
Tesztelés HTTPie klienssel:
http localhost:5500/msg
app()->post('/msg', function() { response()->json(['msg' => 'üdv']); });
Tesztelés HTTPie klienssel:
http post localhost:5500/msg
app()->post('employees', function() { $name = request()->get('name'); response()->json(['name' => $name]); });
Tesztelés HTTPie klienssel:
http post localhost:5500/employees name="Béla"
app()->put('employees/{id}', function() { $name = request()->get('name'); response()->json(['name' => $name]); });
Tesztelés HTTPie klienssel:
http put localhost:5500/employees/23 name="Béla"
app()->delete('employees/{id}', function($id) { response()->json(['for_delete' => $id]); });
Tesztelés HTTPie klienssel:
http delete localhost:5500/employees/23
app()->resource('/employees', 'EmployeeController'); app()->run();
Olyan mintha ezt írtam volna:
app()->match('GET|HEAD', '/employees', "$controller@index"); app()->post('/employees', "$controller@store"); app()->match('GET|HEAD', '/employees/create', "$controller@create"); app()->match('POST|DELETE', '/employees/{id}/delete', "$controller@destroy"); app()->match('POST|PUT|PATCH', '/employees/{id}/edit', "$controller@update"); app()->match('GET|HEAD', '/employees/{id}/edit', "$controller@edit"); app()->match('GET|HEAD', '/employees/{id}', "$controller@show"); app()->run();
Dokumentáció: