Skip to content

Commit ade967a

Browse files
committed
init project
1 parent 43b7b6f commit ade967a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+11237
-4
lines changed

.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 4
7+
indent_style = space
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2
16+
17+
[docker-compose.yml]
18+
indent_size = 4

.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
DB_CONNECTION=mariadb
2+
DB_HOST=127.0.0.1
3+
DB_PORT=3306
4+
DB_DATABASE=laravel_php_mariadb_demo
5+
DB_USERNAME=root
6+
DB_PASSWORD=

.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
* text=auto eol=lf
2+
3+
*.blade.php diff=html
4+
*.css diff=css
5+
*.html diff=html
6+
*.md diff=markdown
7+
*.php diff=php
8+
9+
/.github export-ignore
10+
CHANGELOG.md export-ignore
11+
.styleci.yml export-ignore

.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/.phpunit.cache
2+
/node_modules
3+
/public/build
4+
/public/hot
5+
/public/storage
6+
/storage/*.key
7+
/storage/pail
8+
/vendor
9+
.env
10+
.env.backup
11+
.env.production
12+
.phpactor.json
13+
.phpunit.result.cache
14+
Homestead.json
15+
Homestead.yaml
16+
npm-debug.log
17+
yarn-error.log
18+
/auth.json
19+
/.fleet
20+
/.idea
21+
/.nova
22+
/.vscode
23+
/.zed

README.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
# Laravel PHP MariaDB Demo
22

3+
## Prerequisites
4+
5+
** PR (Phhp 9.x or higher)
6+
** Composer (Package Manager)
7+
** MariaDB 10.x running on MacOS
8+
39
## Installation
410

5-
### 1. Install PHP, Composer, and MariaDB
6-
```
7-
bash setup-mac/macsetup.sh
11+
### 1. Clone the repository:
12+
13+
```sh
14+
git clone https://github.com/serverlesssalad/laravel-php-mariadb-demo.git
15+
cd laravel-php-mariadb-demo
816
```
917

1018
### 2. Configure `.env` file:
@@ -31,5 +39,10 @@ php artisan migrate
3139
php artisan serve
3240
```
3341

34-
Access Test: http://127.0.0.1:8000/api/words
42+
## API Test
43+
44+
### GET words
45+
```sh
46+
curl -X POST http://127.0.0.1:8000/api/words
47+
```
3548

app/Http/Controllers/Controller.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
abstract class Controller
6+
{
7+
//
8+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use Illuminate\Http\Request;
6+
use App\Models\Word;
7+
8+
class WordController extends Controller
9+
{
10+
public function index()
11+
{
12+
return response()->json(Word::all());
13+
}
14+
15+
public function store(Request $request)
16+
{
17+
$request->validate(['word' => 'required|string|unique:words,word']);
18+
$word = Word::create($request->only('word'));
19+
return response()->json($word, 201);
20+
}
21+
22+
public function show($id)
23+
{
24+
$word = Word::findOrFail($id);
25+
return response()->json($word);
26+
}
27+
28+
public function update(Request $request, $id)
29+
{
30+
$word = Word::findOrFail($id);
31+
$request->validate(['word' => 'required|string|unique:words,word']);
32+
$word->update($request->only('word'));
33+
return response()->json($word);
34+
}
35+
36+
public function destroy($id)
37+
{
38+
Word::destroy($id);
39+
return response()->json(['message' => 'Word deleted successfully']);
40+
}
41+
}

app/Models/User.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
// use Illuminate\Contracts\Auth\MustVerifyEmail;
6+
use Illuminate\Database\Eloquent\Factories\HasFactory;
7+
use Illuminate\Foundation\Auth\User as Authenticatable;
8+
use Illuminate\Notifications\Notifiable;
9+
10+
class User extends Authenticatable
11+
{
12+
/** @use HasFactory<\Database\Factories\UserFactory> */
13+
use HasFactory, Notifiable;
14+
15+
/**
16+
* The attributes that are mass assignable.
17+
*
18+
* @var list<string>
19+
*/
20+
protected $fillable = [
21+
'name',
22+
'email',
23+
'password',
24+
];
25+
26+
/**
27+
* The attributes that should be hidden for serialization.
28+
*
29+
* @var list<string>
30+
*/
31+
protected $hidden = [
32+
'password',
33+
'remember_token',
34+
];
35+
36+
/**
37+
* Get the attributes that should be cast.
38+
*
39+
* @return array<string, string>
40+
*/
41+
protected function casts(): array
42+
{
43+
return [
44+
'email_verified_at' => 'datetime',
45+
'password' => 'hashed',
46+
];
47+
}
48+
}

app/Models/Word.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use Illuminate\Database\Eloquent\Factories\HasFactory;
6+
use Illuminate\Database\Eloquent\Model;
7+
8+
class Word extends Model
9+
{
10+
use HasFactory;
11+
12+
protected $fillable = ['word'];
13+
}

app/Providers/AppServiceProvider.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace App\Providers;
4+
5+
use Illuminate\Support\ServiceProvider;
6+
7+
class AppServiceProvider extends ServiceProvider
8+
{
9+
/**
10+
* Register any application services.
11+
*/
12+
public function register(): void
13+
{
14+
//
15+
}
16+
17+
/**
18+
* Bootstrap any application services.
19+
*/
20+
public function boot(): void
21+
{
22+
//
23+
}
24+
}

artisan

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
use Symfony\Component\Console\Input\ArgvInput;
5+
6+
define('LARAVEL_START', microtime(true));
7+
8+
// Register the Composer autoloader...
9+
require __DIR__.'/vendor/autoload.php';
10+
11+
// Bootstrap Laravel and handle the command...
12+
$status = (require_once __DIR__.'/bootstrap/app.php')
13+
->handleCommand(new ArgvInput);
14+
15+
exit($status);

bootstrap/app.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
use Illuminate\Foundation\Application;
4+
use Illuminate\Foundation\Configuration\Exceptions;
5+
use Illuminate\Foundation\Configuration\Middleware;
6+
7+
return Application::configure(basePath: dirname(__DIR__))
8+
->withRouting(
9+
web: __DIR__.'/../routes/web.php',
10+
commands: __DIR__.'/../routes/console.php',
11+
health: '/up',
12+
)
13+
->withMiddleware(function (Middleware $middleware) {
14+
//
15+
})
16+
->withExceptions(function (Exceptions $exceptions) {
17+
//
18+
})->create();

bootstrap/cache/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

bootstrap/providers.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
return [
4+
App\Providers\AppServiceProvider::class,
5+
];

composer.json

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"$schema": "https://getcomposer.org/schema.json",
3+
"name": "laravel/laravel",
4+
"type": "project",
5+
"description": "The skeleton application for the Laravel framework.",
6+
"keywords": [
7+
"laravel",
8+
"framework"
9+
],
10+
"license": "MIT",
11+
"require": {
12+
"php": "^8.2",
13+
"laravel/framework": "^11.31",
14+
"laravel/tinker": "^2.9"
15+
},
16+
"require-dev": {
17+
"fakerphp/faker": "^1.23",
18+
"laravel/pail": "^1.1",
19+
"laravel/pint": "^1.13",
20+
"laravel/sail": "^1.26",
21+
"mockery/mockery": "^1.6",
22+
"nunomaduro/collision": "^8.1",
23+
"pestphp/pest": "^3.7",
24+
"pestphp/pest-plugin-laravel": "^3.1"
25+
},
26+
"autoload": {
27+
"psr-4": {
28+
"App\\": "app/",
29+
"Database\\Factories\\": "database/factories/",
30+
"Database\\Seeders\\": "database/seeders/"
31+
}
32+
},
33+
"autoload-dev": {
34+
"psr-4": {
35+
"Tests\\": "tests/"
36+
}
37+
},
38+
"scripts": {
39+
"post-autoload-dump": [
40+
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
41+
"@php artisan package:discover --ansi"
42+
],
43+
"post-update-cmd": [
44+
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
45+
],
46+
"post-root-package-install": [
47+
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
48+
],
49+
"post-create-project-cmd": [
50+
"@php artisan key:generate --ansi",
51+
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
52+
"@php artisan migrate --graceful --ansi"
53+
],
54+
"dev": [
55+
"Composer\\Config::disableProcessTimeout",
56+
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite"
57+
]
58+
},
59+
"extra": {
60+
"laravel": {
61+
"dont-discover": []
62+
}
63+
},
64+
"config": {
65+
"optimize-autoloader": true,
66+
"preferred-install": "dist",
67+
"sort-packages": true,
68+
"allow-plugins": {
69+
"pestphp/pest-plugin": true,
70+
"php-http/discovery": true
71+
}
72+
},
73+
"minimum-stability": "stable",
74+
"prefer-stable": true
75+
}

0 commit comments

Comments
 (0)