Created
December 2, 2016 22:05
-
-
Save collegeman/88548ad255e4cb1335bb143d29bce9e0 to your computer and use it in GitHub Desktop.
You can't use Laravel Facades in Illuminated WordPress Plugins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace YourPlugin; | |
class YourPlugin extends \FatPanda\Illuminate\WordPress\Plugin | |
{ | |
/** | |
* You can't use the DB Facade, even though this would be syntactically | |
* valid in Laravel—the reason is that unlike in a Laravel App, in | |
* WordPress, there's potentially more than one Container per request— | |
* so the Facades can't know which Container they should ask to get | |
* the referenced component. Sorry! | |
*/ | |
function onInit() | |
{ | |
$latestPosts = DB::table('posts')->all(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment