Skip to content

Commit 2d43544

Browse files
committed
Add controller blog example
1 parent f0bae61 commit 2d43544

File tree

10 files changed

+139
-8
lines changed

10 files changed

+139
-8
lines changed

Dockerfile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1-
FROM php:7.4-fpm-alpine
1+
FROM php:7.4.5-fpm-alpine
22

33
WORKDIR /var/www/html
44

55
RUN apk update apk add --no-cache \
66
curl \
77
vim \
88
wget \
9-
bash \
109
libfreetype6-dev \
1110
libjpeg62-turbo-dev \
1211
libmcrypt-dev \
13-
libpng-dev
12+
libpng-dev \
13+
libonig-dev
1414

1515
RUN set -ex \
1616
&& apk --no-cache add \
1717
postgresql-dev
1818

19-
RUN docker-php-ext-install pdo pdo_pgsql \
19+
RUN docker-php-ext-install \
20+
pdo \
21+
pdo_pgsql \
2022
&& apk --no-cache add pcre-dev ${PHPIZE_DEPS} \
2123
&& pecl install xdebug \
2224
&& docker-php-ext-enable xdebug \
23-
&& apk del pcre-dev ${PHPIZE_DEPS}
25+
&& apk del pcre-dev ${PHPIZE_DEPS}

resumeAt.txt.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://laracasts.com/series/laravel-6-from-scratch/episodes/6?autoplay=true
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use Illuminate\Http\Request;
6+
7+
class NameController extends Controller
8+
{
9+
public function requestAsJson (Request $request) {
10+
return $request;
11+
}
12+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use Illuminate\Http\Request;
6+
7+
class PostController extends Controller
8+
{
9+
public function show($post)
10+
{
11+
$posts = [
12+
'my-first-post' => 'Hello, thisis my first blog post!',
13+
'my-second-post' => 'Now I am getting the hang of this blogging thing.',
14+
];
15+
16+
if(!array_key_exists($post, $posts)) {
17+
abort(404, 'Sorry, that post was not found.');
18+
}
19+
20+
return view('post', [
21+
'post' => $posts[$post]
22+
]);
23+
}
24+
}

src/public/php_test.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+

src/resources/views/phpinfo.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
phpinfo();

src/resources/views/post.blade.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<title>Document</title>
8+
</head>
9+
<body>
10+
<h1>My Blog Post</h1>
11+
<p>{{ $post }}</p>
12+
</body>
13+
</html>

src/resources/views/test.blade.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
3+
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
4+
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
5+
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
6+
<head>
7+
<meta charset="utf-8">
8+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
9+
<title></title>
10+
<meta name="description" content="">
11+
<meta name="viewport" content="width=device-width, initial-scale=1">
12+
<link rel="stylesheet" href="">
13+
</head>
14+
<body>
15+
<!--[if lt IE 7]>
16+
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
17+
<![endif]-->
18+
<h1><?= $name; ?></h1>
19+
20+
<script src="" async defer></script>
21+
</body>
22+
</html>

src/resources/views/user.blade.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<title>Document</title>
8+
</head>
9+
<body>
10+
<h1>Name: <?= {{ $name; }}?></h1>
11+
{{-- <h1>Name: <?= htmlspecialchars($name, ENT_QUOTES); ?></h1> --}}
12+
</body>
13+
</html>

src/routes/web.php

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,45 @@
1313
|
1414
*/
1515

16-
Route::get('/', function () {
17-
return view('welcome');
18-
});
16+
// Route::view('/', 'welcome');
17+
18+
// Route::get('test', function() {
19+
// $name = request('name');
20+
// return view('test', [
21+
// 'name' => $name
22+
// ]);
23+
// });
24+
25+
// Route::get('/phpinfo', function () {
26+
// return view("phpinfo");
27+
// });
28+
29+
// Route::get('/jsonArr', function() {
30+
// return ['Name' => 'Luke'];
31+
// });
32+
33+
// Route::get('/service1', function() {
34+
// $name = request('name');
35+
// return $name;
36+
// });
37+
38+
// Route::get('/', 'NameController@requestAsJson');
39+
40+
// Route::get('/posts/{post}', function($post) {
41+
// $posts = [
42+
// 'my-first-post' => 'Hello, this is my first blog post!',
43+
// 'my-second-post' => 'Now I am getting the hang of this blogging thing.'
44+
// ];
45+
46+
// if(! array_key_exists($post, $posts))
47+
// {
48+
// abort(404, 'Sorry that post was not found.');
49+
// }
50+
51+
// return view('post', [
52+
// 'post' => $posts[$post] ?? 'Nothing here yet.'
53+
// ]);
54+
// });
55+
56+
57+
Route::get('/posts/{post}', 'PostController@show');

0 commit comments

Comments
 (0)