├── .gitignore ├── LICENSE ├── README.md └── wl-bootstrap.php /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | _ide_helper.php 3 | .phpstorm.meta.php -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Golr 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | WordPress Laravel Bootstrap 2 | ====== 3 | 4 | > A WordPress plugin helps you use functions, methods, libraries of Laravel in any WordPress projects 5 | 6 | ## Requiments 7 | 8 | - Laravel >= 5.2 9 | - WordPress >= 4.6 10 | 11 | ## Installation 12 | 13 | - Copy "wl-bootstrap" folder into "wp-content/plugins" 14 | - Define Laravel source code path in "wp-config.php" as a constant: 15 | 16 | ``` 17 | define('LARAVEL_PATH', '/srv/www/laravel-example-project'); // Make sure this is pointed to same server 18 | ``` 19 | 20 | ## Usage 21 | 22 | You can use all codes in your Laravel project, build Single Sign On with less effort on same/subdomain and so on... 23 | 24 | ```php 25 | 'Desk'], 'price', 100); 29 | 30 | // Session 31 | session(['chairs' => 7, 'instruments' => 3]); 32 | 33 | // Authentication 34 | Auth::check(); 35 | 36 | // Query Builder 37 | $users = DB::table('users')->get(); 38 | 39 | // Eloquent 40 | $flights = App\Flight::where('active', 1) 41 | ->orderBy('name', 'desc') 42 | ->take(10) 43 | ->get(); 44 | 45 | ``` 46 | 47 | ## Contributing 48 | 49 | All contributions are welcome to help improve WL-Bootstrap. 50 | 51 | ## License 52 | 53 | [MIT](http://opensource.org/licenses/MIT) 54 | 55 | Copyright (c) 2017-present, Golr 56 | -------------------------------------------------------------------------------- /wl-bootstrap.php: -------------------------------------------------------------------------------- 1 | make(\Illuminate\Contracts\Http\Kernel::class); 24 | $request = \Illuminate\Http\Request::capture(); 25 | 26 | $app->instance('request', $request); 27 | $kernel->bootstrap(); 28 | 29 | $response = (new \Illuminate\Routing\Pipeline($app)) 30 | ->send($request) 31 | ->through([ 32 | \App\Http\Middleware\EncryptCookies::class, 33 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, 34 | \Illuminate\Session\Middleware\StartSession::class 35 | ]) 36 | ->then(function () { 37 | return response('', 200, []); 38 | }); 39 | 40 | // Set cookie from response headers 41 | foreach ($response->headers->getCookies() as $cookie) { 42 | if ($cookie->isRaw()) { 43 | setrawcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly()); 44 | } else { 45 | setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly()); 46 | } 47 | } 48 | } 49 | 50 | add_action('plugins_loaded', 'wl_bootstrap'); 51 | --------------------------------------------------------------------------------