From 2b67d8cbe56fc5de9fe187c7e1c5f9d00661d615 Mon Sep 17 00:00:00 2001 From: Laravel Shift Date: Thu, 20 Jul 2017 17:03:36 +0000 Subject: [PATCH 1/6] Shift Middleware --- app/Http/Kernel.php | 4 ++++ app/Http/Middleware/TrimStrings.php | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 app/Http/Middleware/TrimStrings.php diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index bcabec4..66d34c3 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -15,6 +15,9 @@ class Kernel extends HttpKernel */ protected $middleware = [ \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class, + \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, + \App\Http\Middleware\TrimStrings::class, + \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, ]; /** @@ -27,6 +30,7 @@ class Kernel extends HttpKernel \App\Http\Middleware\EncryptCookies::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Session\Middleware\StartSession::class, + // \Illuminate\Session\Middleware\AuthenticateSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, diff --git a/app/Http/Middleware/TrimStrings.php b/app/Http/Middleware/TrimStrings.php new file mode 100644 index 0000000..943e9a4 --- /dev/null +++ b/app/Http/Middleware/TrimStrings.php @@ -0,0 +1,18 @@ + Date: Thu, 20 Jul 2017 17:03:36 +0000 Subject: [PATCH 2/6] Shift Providers --- app/Providers/BroadcastServiceProvider.php | 7 +------ app/Providers/RouteServiceProvider.php | 20 +++++++------------- routes/channels.php | 16 ++++++++++++++++ 3 files changed, 24 insertions(+), 19 deletions(-) create mode 100644 routes/channels.php diff --git a/app/Providers/BroadcastServiceProvider.php b/app/Providers/BroadcastServiceProvider.php index 1dcf8d2..352cce4 100644 --- a/app/Providers/BroadcastServiceProvider.php +++ b/app/Providers/BroadcastServiceProvider.php @@ -16,11 +16,6 @@ public function boot() { Broadcast::routes(); - /* - * Authenticate the user's personal channel... - */ - Broadcast::channel('App.User.*', function ($user, $userId) { - return (int) $user->id === (int) $userId; - }); + require base_path('routes/channels.php'); } } diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 87ffb05..5ea48d3 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -51,12 +51,9 @@ public function map() */ protected function mapWebRoutes() { - Route::group([ - 'middleware' => 'web', - 'namespace' => $this->namespace, - ], function ($router) { - require base_path('routes/web.php'); - }); + Route::middleware('web') + ->namespace($this->namespace) + ->group(base_path('routes/web.php')); } /** @@ -68,12 +65,9 @@ protected function mapWebRoutes() */ protected function mapApiRoutes() { - Route::group([ - 'middleware' => 'api', - 'namespace' => $this->namespace, - 'prefix' => 'api', - ], function ($router) { - require base_path('routes/api.php'); - }); + Route::prefix('api') + ->middleware('api') + ->namespace($this->namespace) + ->group(base_path('routes/api.php')); } } diff --git a/routes/channels.php b/routes/channels.php new file mode 100644 index 0000000..f16a20b --- /dev/null +++ b/routes/channels.php @@ -0,0 +1,16 @@ +id === (int) $id; +}); From 220459be3648422f8fec090f1e78fb5f6dde9668 Mon Sep 17 00:00:00 2001 From: Laravel Shift Date: Thu, 20 Jul 2017 17:03:36 +0000 Subject: [PATCH 3/6] Shift assets --- gulpfile.js | 19 ---------------- package.json | 23 ++++++++++--------- resources/assets/js/bootstrap.js | 38 +++++++++++++++++++------------- webpack.mix.js | 15 +++++++++++++ 4 files changed, 51 insertions(+), 44 deletions(-) delete mode 100644 gulpfile.js create mode 100644 webpack.mix.js diff --git a/gulpfile.js b/gulpfile.js deleted file mode 100644 index c9de6ea..0000000 --- a/gulpfile.js +++ /dev/null @@ -1,19 +0,0 @@ -const elixir = require('laravel-elixir'); - -require('laravel-elixir-vue-2'); - -/* - |-------------------------------------------------------------------------- - | Elixir Asset Management - |-------------------------------------------------------------------------- - | - | Elixir provides a clean, fluent API for defining some basic Gulp tasks - | for your Laravel application. By default, we are compiling the Sass - | file for your application as well as publishing vendor resources. - | - */ - -elixir((mix) => { - mix.sass('app.scss') - .webpack('app.js'); -}); diff --git a/package.json b/package.json index f4f49c8..630a244 100644 --- a/package.json +++ b/package.json @@ -1,18 +1,21 @@ { "private": true, "scripts": { - "prod": "gulp --production", - "dev": "gulp watch" + "dev": "npm run development", + "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", + "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", + "watch-poll": "npm run watch -- --watch-poll", + "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", + "prod": "npm run production", + "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" }, "devDependencies": { + "axios": "^0.16.2", "bootstrap-sass": "^3.3.7", - "gulp": "^3.9.1", - "jquery": "^3.1.0", - "laravel-elixir": "^6.0.0-14", - "laravel-elixir-vue-2": "^0.2.0", - "laravel-elixir-webpack-official": "^1.0.2", - "lodash": "^4.16.2", - "vue": "^2.0.1", - "vue-resource": "^1.0.3" + "cross-env": "^5.0.1", + "jquery": "^3.1.1", + "laravel-mix": "^1.0", + "lodash": "^4.17.4", + "vue": "^2.1.10" } } diff --git a/resources/assets/js/bootstrap.js b/resources/assets/js/bootstrap.js index a2f3529..8e0f04e 100644 --- a/resources/assets/js/bootstrap.js +++ b/resources/assets/js/bootstrap.js @@ -7,29 +7,35 @@ window._ = require('lodash'); * code may be modified to fit the specific needs of your application. */ -window.$ = window.jQuery = require('jquery'); -require('bootstrap-sass'); +try { + window.$ = window.jQuery = require('jquery'); + + require('bootstrap-sass'); +} catch (e) {} /** - * Vue is a modern JavaScript library for building interactive web interfaces - * using reactive data binding and reusable components. Vue's API is clean - * and simple, leaving you to focus on building your next great project. + * We'll load the axios HTTP library which allows us to easily issue requests + * to our Laravel back-end. This library automatically handles sending the + * CSRF token as a header based on the value of the "XSRF" token cookie. */ -window.Vue = require('vue'); -require('vue-resource'); +window.axios = require('axios'); + +window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; /** - * We'll register a HTTP interceptor to attach the "CSRF" header to each of - * the outgoing requests issued by this application. The CSRF middleware - * included with Laravel will automatically verify the header's value. + * Next we will register the CSRF Token as a common header with Axios so that + * all outgoing HTTP requests automatically have it attached. This is just + * a simple convenience so we don't have to attach every token manually. */ -Vue.http.interceptors.push((request, next) => { - request.headers.set('X-CSRF-TOKEN', Laravel.csrfToken); +let token = document.head.querySelector('meta[name="csrf-token"]'); - next(); -}); +if (token) { + window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content; +} else { + console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token'); +} /** * Echo exposes an expressive API for subscribing to channels and listening @@ -37,7 +43,9 @@ Vue.http.interceptors.push((request, next) => { * allows your team to easily build robust real-time web applications. */ -// import Echo from "laravel-echo" +// import Echo from 'laravel-echo' + +// window.Pusher = require('pusher-js'); // window.Echo = new Echo({ // broadcaster: 'pusher', diff --git a/webpack.mix.js b/webpack.mix.js new file mode 100644 index 0000000..72fdbb1 --- /dev/null +++ b/webpack.mix.js @@ -0,0 +1,15 @@ +let mix = require('laravel-mix'); + +/* + |-------------------------------------------------------------------------- + | Mix Asset Management + |-------------------------------------------------------------------------- + | + | Mix provides a clean, fluent API for defining some Webpack build steps + | for your Laravel application. By default, we are compiling the Sass + | file for the application as well as bundling up all the JS files. + | + */ + +mix.js('resources/assets/js/app.js', 'public/js') + .sass('resources/assets/sass/app.scss', 'public/css'); From 9eb6af9a612d258a0ac5fecec8d68208f1c81013 Mon Sep 17 00:00:00 2001 From: Laravel Shift Date: Thu, 20 Jul 2017 17:03:36 +0000 Subject: [PATCH 4/6] Shift configuration --- bootstrap/autoload.php | 21 ++------------------- config/app.php | 6 +++--- config/broadcasting.php | 4 ++-- config/cache.php | 2 +- config/compile.php | 35 ----------------------------------- config/database.php | 31 +++++++++++++++---------------- config/filesystems.php | 13 +++++++------ config/mail.php | 32 ++++++++++++++++++++------------ config/queue.php | 2 +- config/view.php | 2 +- 10 files changed, 52 insertions(+), 96 deletions(-) delete mode 100644 config/compile.php diff --git a/bootstrap/autoload.php b/bootstrap/autoload.php index 3830137..c64e19f 100644 --- a/bootstrap/autoload.php +++ b/bootstrap/autoload.php @@ -9,26 +9,9 @@ | | Composer provides a convenient, automatically generated class loader | for our application. We just need to utilize it! We'll require it -| into the script here so that we do not have to worry about the -| loading of any our classes "manually". Feels great to relax. +| into the script here so we do not have to manually load any of +| our application's PHP classes. It just feels great to relax. | */ require __DIR__.'/../vendor/autoload.php'; - -/* -|-------------------------------------------------------------------------- -| Include The Compiled Class File -|-------------------------------------------------------------------------- -| -| To dramatically increase your application's performance, you may use a -| compiled class file which contains all of the classes commonly used -| by a request. The Artisan "optimize" is used to create this file. -| -*/ - -$compiledPath = __DIR__.'/cache/compiled.php'; - -if (file_exists($compiledPath)) { - require $compiledPath; -} diff --git a/config/app.php b/config/app.php index 717ee98..135e977 100644 --- a/config/app.php +++ b/config/app.php @@ -12,7 +12,7 @@ | any other location as required by the application or its packages. */ - 'name' => 'Laravel', + 'name' => env('APP_NAME', 'Laravel'), /* |-------------------------------------------------------------------------- @@ -166,8 +166,7 @@ /* * Package Service Providers... */ - - // + Laravel\Tinker\TinkerServiceProvider::class, /* * Application Service Providers... @@ -197,6 +196,7 @@ 'Artisan' => Illuminate\Support\Facades\Artisan::class, 'Auth' => Illuminate\Support\Facades\Auth::class, 'Blade' => Illuminate\Support\Facades\Blade::class, + 'Broadcast' => Illuminate\Support\Facades\Broadcast::class, 'Bus' => Illuminate\Support\Facades\Bus::class, 'Cache' => Illuminate\Support\Facades\Cache::class, 'Config' => Illuminate\Support\Facades\Config::class, diff --git a/config/broadcasting.php b/config/broadcasting.php index 19a59ba..5eecd2b 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -32,8 +32,8 @@ 'pusher' => [ 'driver' => 'pusher', - 'key' => env('PUSHER_KEY'), - 'secret' => env('PUSHER_SECRET'), + 'key' => env('PUSHER_APP_KEY'), + 'secret' => env('PUSHER_APP_SECRET'), 'app_id' => env('PUSHER_APP_ID'), 'options' => [ // diff --git a/config/cache.php b/config/cache.php index 1d3de87..e87f032 100644 --- a/config/cache.php +++ b/config/cache.php @@ -46,7 +46,7 @@ 'file' => [ 'driver' => 'file', - 'path' => storage_path('framework/cache'), + 'path' => storage_path('framework/cache/data'), ], 'memcached' => [ diff --git a/config/compile.php b/config/compile.php deleted file mode 100644 index 04807ea..0000000 --- a/config/compile.php +++ /dev/null @@ -1,35 +0,0 @@ - [ - // - ], - - /* - |-------------------------------------------------------------------------- - | Compiled File Providers - |-------------------------------------------------------------------------- - | - | Here you may list service providers which define a "compiles" function - | that returns additional files that should be compiled, providing an - | easy way to get common files from any packages you are utilizing. - | - */ - - 'providers' => [ - // - ], - -]; diff --git a/config/database.php b/config/database.php index 1b87e0f..cab5d06 100644 --- a/config/database.php +++ b/config/database.php @@ -2,19 +2,6 @@ return [ - /* - |-------------------------------------------------------------------------- - | PDO Fetch Style - |-------------------------------------------------------------------------- - | - | By default, database results will be returned as instances of the PHP - | stdClass object; however, you may desire to retrieve records in an - | array format for simplicity. Here you can tweak the fetch style. - | - */ - - 'fetch' => PDO::FETCH_OBJ, - /* |-------------------------------------------------------------------------- | Default Database Connection Name @@ -59,8 +46,9 @@ 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), - 'charset' => 'utf8', - 'collation' => 'utf8_unicode_ci', + 'unix_socket' => env('DB_SOCKET', ''), + 'charset' => 'utf8mb4', + 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'strict' => true, 'engine' => null, @@ -79,6 +67,17 @@ 'sslmode' => 'prefer', ], + 'sqlsrv' => [ + 'driver' => 'sqlsrv', + 'host' => env('DB_HOST', 'localhost'), + 'port' => env('DB_PORT', '1433'), + 'database' => env('DB_DATABASE', 'forge'), + 'username' => env('DB_USERNAME', 'forge'), + 'password' => env('DB_PASSWORD', ''), + 'charset' => 'utf8', + 'prefix' => '', + ], + ], /* @@ -107,7 +106,7 @@ 'redis' => [ - 'cluster' => false, + 'client' => 'predis', 'default' => [ 'host' => env('REDIS_HOST', '127.0.0.1'), diff --git a/config/filesystems.php b/config/filesystems.php index e1c4c95..4544f60 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -13,7 +13,7 @@ | */ - 'default' => 'local', + 'default' => env('FILESYSTEM_DRIVER', 'local'), /* |-------------------------------------------------------------------------- @@ -26,7 +26,7 @@ | */ - 'cloud' => 's3', + 'cloud' => env('FILESYSTEM_CLOUD', 's3'), /* |-------------------------------------------------------------------------- @@ -51,15 +51,16 @@ 'public' => [ 'driver' => 'local', 'root' => storage_path('app/public'), + 'url' => env('APP_URL').'/storage', 'visibility' => 'public', ], 's3' => [ 'driver' => 's3', - 'key' => 'your-key', - 'secret' => 'your-secret', - 'region' => 'your-region', - 'bucket' => 'your-bucket', + 'key' => env('AWS_KEY'), + 'secret' => env('AWS_SECRET'), + 'region' => env('AWS_REGION'), + 'bucket' => env('AWS_BUCKET'), ], ], diff --git a/config/mail.php b/config/mail.php index 73c691f..bb92224 100644 --- a/config/mail.php +++ b/config/mail.php @@ -11,8 +11,8 @@ | sending of e-mail. You may specify which one you're using throughout | your application here. By default, Laravel is setup for SMTP mail. | - | Supported: "smtp", "mail", "sendmail", "mailgun", "mandrill", - | "ses", "sparkpost", "log" + | Supported: "smtp", "sendmail", "mailgun", "mandrill", "ses", + | "sparkpost", "log", "array" | */ @@ -86,30 +86,38 @@ 'username' => env('MAIL_USERNAME'), + 'password' => env('MAIL_PASSWORD'), + /* |-------------------------------------------------------------------------- - | SMTP Server Password + | Sendmail System Path |-------------------------------------------------------------------------- | - | Here you may set the password required by your SMTP server to send out - | messages from your application. This will be given to the server on - | connection so that the application will be able to send messages. + | When using the "sendmail" driver to send e-mails, we will need to know + | the path to where Sendmail lives on this server. A default path has + | been provided here, which will work well on most of your systems. | */ - 'password' => env('MAIL_PASSWORD'), + 'sendmail' => '/usr/sbin/sendmail -bs', /* |-------------------------------------------------------------------------- - | Sendmail System Path + | Markdown Mail Settings |-------------------------------------------------------------------------- | - | When using the "sendmail" driver to send e-mails, we will need to know - | the path to where Sendmail lives on this server. A default path has - | been provided here, which will work well on most of your systems. + | If you are using Markdown based email rendering, you may configure your + | theme and component paths here, allowing you to customize the design + | of the emails. Or, you may simply stick with the Laravel defaults! | */ - 'sendmail' => '/usr/sbin/sendmail -bs', + 'markdown' => [ + 'theme' => 'default', + + 'paths' => [ + resource_path('views/vendor/mail'), + ], + ], ]; diff --git a/config/queue.php b/config/queue.php index 549322e..4d83ebd 100644 --- a/config/queue.php +++ b/config/queue.php @@ -7,7 +7,7 @@ | Default Queue Driver |-------------------------------------------------------------------------- | - | The Laravel queue API supports a variety of back-ends via an unified + | Laravel's queue API supports an assortment of back-ends via a single | API, giving you convenient access to each back-end using the same | syntax for each one. Here you may set the default queue driver. | diff --git a/config/view.php b/config/view.php index e193ab6..2acfd9c 100644 --- a/config/view.php +++ b/config/view.php @@ -14,7 +14,7 @@ */ 'paths' => [ - realpath(base_path('resources/views')), + resource_path('views'), ], /* From 8caaf8a5a954201cb1c81c23294c505ea8c65188 Mon Sep 17 00:00:00 2001 From: Laravel Shift Date: Thu, 20 Jul 2017 17:03:36 +0000 Subject: [PATCH 5/6] Shift tests --- composer.json | 13 ++++++++----- phpunit.xml | 8 ++++++-- tests/CreatesApplication.php | 22 ++++++++++++++++++++++ tests/{ => Feature}/ExampleTest.php | 12 ++++++++---- tests/TestCase.php | 25 +++++-------------------- tests/Unit/ExampleTest.php | 20 ++++++++++++++++++++ 6 files changed, 69 insertions(+), 31 deletions(-) create mode 100644 tests/CreatesApplication.php rename tests/{ => Feature}/ExampleTest.php (58%) create mode 100644 tests/Unit/ExampleTest.php diff --git a/composer.json b/composer.json index a94eb33..9089152 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,10 @@ { "name": "laravel/laravel", "description": "The Laravel Framework.", - "keywords": ["framework", "laravel"], + "keywords": [ + "framework", + "laravel" + ], "license": "MIT", "type": "project", "require": { @@ -24,9 +27,9 @@ } }, "autoload-dev": { - "classmap": [ - "tests/TestCase.php" - ] + "psr-4": { + "Tests\\": "tests/" + } }, "scripts": { "post-root-package-install": [ @@ -48,4 +51,4 @@ "preferred-install": "dist", "sort-packages": true } -} +} \ No newline at end of file diff --git a/phpunit.xml b/phpunit.xml index 712e0af..9ecda83 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -9,8 +9,12 @@ processIsolation="false" stopOnFailure="false"> - - ./tests + + ./tests/Feature + + + + ./tests/Unit diff --git a/tests/CreatesApplication.php b/tests/CreatesApplication.php new file mode 100644 index 0000000..547152f --- /dev/null +++ b/tests/CreatesApplication.php @@ -0,0 +1,22 @@ +make(Kernel::class)->bootstrap(); + + return $app; + } +} diff --git a/tests/ExampleTest.php b/tests/Feature/ExampleTest.php similarity index 58% rename from tests/ExampleTest.php rename to tests/Feature/ExampleTest.php index 2f2d20f..486dc27 100644 --- a/tests/ExampleTest.php +++ b/tests/Feature/ExampleTest.php @@ -1,5 +1,8 @@ visit('/') - ->see('Laravel'); + $response = $this->get('/'); + + $response->assertStatus(200); } } diff --git a/tests/TestCase.php b/tests/TestCase.php index 8208edc..2932d4a 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -1,25 +1,10 @@ make(Illuminate\Contracts\Console\Kernel::class)->bootstrap(); +use Illuminate\Foundation\Testing\TestCase as BaseTestCase; - return $app; - } +abstract class TestCase extends BaseTestCase +{ + use CreatesApplication; } diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php new file mode 100644 index 0000000..5663bb4 --- /dev/null +++ b/tests/Unit/ExampleTest.php @@ -0,0 +1,20 @@ +assertTrue(true); + } +} From b98a7841707f12fb9f759ec5a5e29a998c418a0f Mon Sep 17 00:00:00 2001 From: Laravel Shift Date: Thu, 20 Jul 2017 17:03:41 +0000 Subject: [PATCH 6/6] Shift Laravel dependencies --- composer.json | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 9089152..25933b9 100644 --- a/composer.json +++ b/composer.json @@ -9,14 +9,13 @@ "type": "project", "require": { "php": ">=5.6.4", - "laravel/framework": "5.3.*" + "laravel/framework": "5.4.*", + "laravel/tinker": "~1.0" }, "require-dev": { "fzaninotto/faker": "~1.4", "mockery/mockery": "0.9.*", - "phpunit/phpunit": "~5.0", - "symfony/css-selector": "3.1.*", - "symfony/dom-crawler": "3.1.*" + "phpunit/phpunit": "~5.7" }, "autoload": { "classmap": [