Skip to content

Commit 7d5734c

Browse files
author
ahmadhuss
committed
Initial commit.
0 parents  commit 7d5734c

Some content is hidden

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

83 files changed

+10590
-0
lines changed

.editorconfig

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

.env.example

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
APP_NAME=Laravel
2+
APP_ENV=local
3+
APP_KEY=
4+
APP_DEBUG=true
5+
APP_URL=http://localhost
6+
7+
LOG_CHANNEL=stack
8+
LOG_LEVEL=debug
9+
10+
DB_CONNECTION=mysql
11+
DB_HOST=127.0.0.1
12+
DB_PORT=3306
13+
DB_DATABASE=start_blog
14+
DB_USERNAME=root
15+
DB_PASSWORD=
16+
17+
BROADCAST_DRIVER=log
18+
CACHE_DRIVER=file
19+
QUEUE_CONNECTION=sync
20+
SESSION_DRIVER=file
21+
SESSION_LIFETIME=120
22+
23+
MEMCACHED_HOST=127.0.0.1
24+
25+
REDIS_HOST=127.0.0.1
26+
REDIS_PASSWORD=null
27+
REDIS_PORT=6379
28+
29+
MAIL_MAILER=smtp
30+
MAIL_HOST=mailhog
31+
MAIL_PORT=1025
32+
MAIL_USERNAME=null
33+
MAIL_PASSWORD=null
34+
MAIL_ENCRYPTION=null
35+
MAIL_FROM_ADDRESS=null
36+
MAIL_FROM_NAME="${APP_NAME}"
37+
38+
AWS_ACCESS_KEY_ID=
39+
AWS_SECRET_ACCESS_KEY=
40+
AWS_DEFAULT_REGION=us-east-1
41+
AWS_BUCKET=
42+
43+
PUSHER_APP_ID=
44+
PUSHER_APP_KEY=
45+
PUSHER_APP_SECRET=
46+
PUSHER_APP_CLUSTER=mt1
47+
48+
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
49+
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

.gitattributes

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* text=auto
2+
*.css linguist-vendored
3+
*.scss linguist-vendored
4+
*.js linguist-vendored
5+
CHANGELOG.md export-ignore

.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/node_modules
2+
/public/hot
3+
/public/storage
4+
/storage/*.key
5+
/vendor
6+
.idea
7+
.env
8+
.env.backup
9+
.phpunit.result.cache
10+
docker-compose.override.yml
11+
Homestead.json
12+
Homestead.yaml
13+
npm-debug.log
14+
yarn-error.log

.styleci.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
php:
2+
preset: laravel
3+
disabled:
4+
- no_unused_imports
5+
finder:
6+
not-name:
7+
- index.php
8+
- server.php
9+
js:
10+
finder:
11+
not-name:
12+
- webpack.mix.js
13+
css: true

README.md

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# How can we use this repo?
2+
3+
4+
# Install
5+
```sh
6+
composer install
7+
```
8+
Next you can clone the `.env.example` file into the `.env` file. This means that you have to create the same file in the `root` directory under a different name e.g. `.env` and copy paste the same credentials like `.env.example` file.
9+
10+
Laravel has a built-in CLI tool called `artisan`. Your application must generate a unique base 64 key that Laravel uses behind the scenes to bootstrap this project.
11+
12+
**Command:**
13+
14+
```sh
15+
php artisan key:generate
16+
```
17+
18+
It will automatically find your `.env` file and place the base 64 value in the file.
19+
20+
**Output inside the file:**
21+
```
22+
APP_KEY=base64:T0huMR5Wx9EoDmjTxniKTofHD/7cOiDeVVD9eTKuCa0=
23+
```
24+
25+
## Additional Note:
26+
As you can see it is necessary to create the `.env` file in your local to bootstrap the project. But `Laravel` contains 2 methods to connect to the database server.
27+
28+
- Use of the `.env` variables *(I prefer this one)*
29+
- Use of the file located at the `config/database.php`
30+
31+
32+
33+
## Use of the `.env` variables:
34+
35+
When you create this file with copy paste credentials you can see default; the database variables are written something like this:
36+
```
37+
DB_CONNECTION=mysql
38+
DB_HOST=127.0.0.1
39+
DB_PORT=3306
40+
DB_DATABASE=test_app
41+
DB_USERNAME=root
42+
DB_PASSWORD=
43+
```
44+
45+
You can edit values according to your own database personal preference. I am using Postgres in this case.
46+
47+
## Use of the file located at the `config/database.php`
48+
49+
**Note:** When Laravel bootstraps the project it gives priority to the `.env` file as compared to `config/**` files. You can see `config/database.php` file contains an associated array with default database settings like this.
50+
51+
```
52+
return [
53+
54+
'default' => env('DB_CONNECTION', 'mysql'),
55+
'connections' => [
56+
'mysql' => [
57+
'driver' => 'mysql',
58+
'url' => env('DATABASE_URL'),
59+
'host' => env('DB_HOST', '127.0.0.1'),
60+
'port' => env('DB_PORT', '3306'),
61+
'database' => env('DB_DATABASE', 'forge'),
62+
'username' => env('DB_USERNAME', 'forge'),
63+
'password' => env('DB_PASSWORD', ''),
64+
'unix_socket' => env('DB_SOCKET', ''),
65+
'charset' => 'utf8mb4',
66+
'collation' => 'utf8mb4_unicode_ci',
67+
'prefix' => '',
68+
'prefix_indexes' => true,
69+
'strict' => true,
70+
'engine' => null,
71+
'options' => extension_loaded('pdo_mysql') ? array_filter([
72+
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
73+
]) : [],
74+
],
75+
]
76+
]
77+
```
78+
79+
You can only use these settings if variables from the `.env` file will be deleted. Otherwise, Laravel gives priority to `.env` variables.
80+
81+
Delete the variables from the `.env`:
82+
83+
84+
~~DB_CONNECTION=mysql~~
85+
~~DB_HOST=127.0.0.1~~
86+
~~DB_PORT=3306~~
87+
~~DB_DATABASE=test_app~~
88+
~~DB_USERNAME=root~~
89+
~~DB_PASSWORD=~~
90+
91+
Lastly, Update the `config/database.php` with your database server settings:
92+
93+
```
94+
'default' => env('DB_CONNECTION', 'pgsql')
95+
'database' => env('DB_DATABASE', 'lara8_api'),
96+
'username' => env('DB_USERNAME', 'postgres'),
97+
'password' => env('DB_PASSWORD', 'a')
98+
```
99+
100+
# Database
101+
I am using **Postgres** and inside `.env` file my database server credentials are:
102+
```
103+
DB_CONNECTION=pgsql
104+
DB_HOST=127.0.0.1
105+
DB_PORT=5432
106+
DB_DATABASE=lara8_api
107+
DB_USERNAME=postgres
108+
DB_PASSWORD=a
109+
```
110+
111+
However, your main server and database server get started.
112+
113+
# Migration (Transform into real database tables)
114+
At the last make sure after updating your database settings. Please use `artisan` CLI to migrate the database tables.
115+
```sh
116+
php artisan migrate
117+
```
118+
119+
120+
# Deployment
121+
[Heroku](https://www.heroku.com)

app/Console/Kernel.php

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace App\Console;
4+
5+
use Illuminate\Console\Scheduling\Schedule;
6+
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
7+
8+
class Kernel extends ConsoleKernel
9+
{
10+
/**
11+
* The Artisan commands provided by your application.
12+
*
13+
* @var array
14+
*/
15+
protected $commands = [
16+
//
17+
];
18+
19+
/**
20+
* Define the application's command schedule.
21+
*
22+
* @param \Illuminate\Console\Scheduling\Schedule $schedule
23+
* @return void
24+
*/
25+
protected function schedule(Schedule $schedule)
26+
{
27+
// $schedule->command('inspire')->hourly();
28+
}
29+
30+
/**
31+
* Register the commands for the application.
32+
*
33+
* @return void
34+
*/
35+
protected function commands()
36+
{
37+
$this->load(__DIR__.'/Commands');
38+
39+
require base_path('routes/console.php');
40+
}
41+
}

app/Exceptions/Handler.php

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace App\Exceptions;
4+
5+
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
6+
use Throwable;
7+
8+
class Handler extends ExceptionHandler
9+
{
10+
/**
11+
* A list of the exception types that are not reported.
12+
*
13+
* @var array
14+
*/
15+
protected $dontReport = [
16+
//
17+
];
18+
19+
/**
20+
* A list of the inputs that are never flashed for validation exceptions.
21+
*
22+
* @var array
23+
*/
24+
protected $dontFlash = [
25+
'current_password',
26+
'password',
27+
'password_confirmation',
28+
];
29+
30+
/**
31+
* Register the exception handling callbacks for the application.
32+
*
33+
* @return void
34+
*/
35+
public function register()
36+
{
37+
$this->reportable(function (Throwable $e) {
38+
//
39+
});
40+
}
41+
}

app/Http/Controllers/Controller.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
6+
use Illuminate\Foundation\Bus\DispatchesJobs;
7+
use Illuminate\Foundation\Validation\ValidatesRequests;
8+
use Illuminate\Routing\Controller as BaseController;
9+
10+
class Controller extends BaseController
11+
{
12+
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
13+
}

app/Http/Kernel.php

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
namespace App\Http;
4+
5+
use Illuminate\Foundation\Http\Kernel as HttpKernel;
6+
7+
class Kernel extends HttpKernel
8+
{
9+
/**
10+
* The application's global HTTP middleware stack.
11+
*
12+
* These middleware are run during every request to your application.
13+
*
14+
* @var array
15+
*/
16+
protected $middleware = [
17+
// \App\Http\Middleware\TrustHosts::class,
18+
\App\Http\Middleware\TrustProxies::class,
19+
\Fruitcake\Cors\HandleCors::class,
20+
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
21+
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
22+
\App\Http\Middleware\TrimStrings::class,
23+
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
24+
];
25+
26+
/**
27+
* The application's route middleware groups.
28+
*
29+
* @var array
30+
*/
31+
protected $middlewareGroups = [
32+
'web' => [
33+
\App\Http\Middleware\EncryptCookies::class,
34+
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
35+
\Illuminate\Session\Middleware\StartSession::class,
36+
// \Illuminate\Session\Middleware\AuthenticateSession::class,
37+
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
38+
\App\Http\Middleware\VerifyCsrfToken::class,
39+
\Illuminate\Routing\Middleware\SubstituteBindings::class,
40+
],
41+
42+
'api' => [
43+
'throttle:api',
44+
\Illuminate\Routing\Middleware\SubstituteBindings::class,
45+
],
46+
];
47+
48+
/**
49+
* The application's route middleware.
50+
*
51+
* These middleware may be assigned to groups or used individually.
52+
*
53+
* @var array
54+
*/
55+
protected $routeMiddleware = [
56+
'auth' => \App\Http\Middleware\Authenticate::class,
57+
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
58+
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
59+
'can' => \Illuminate\Auth\Middleware\Authorize::class,
60+
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
61+
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
62+
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
63+
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
64+
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
65+
];
66+
}

0 commit comments

Comments
 (0)