Comments (1)
If you use Slim Framework as a Wordpress plugin then in your routes you have access to Wordpress API.
i would do something like this:
add_action('slim_mapping',function($app){
$app->get('/slim/api/books',function(){
//wordpress current user
$user = wp_get_current_user(); // this function returns current user as a Wp_User object.
if($user->ID > 0) { // it means that there is a user online
//do something as logged in user.
}
});
});
and actually this is how i do it, and i don't use any middlewares.
Also you should not access directly Slim files with include, but use composer autoloader.
So in your code if you need any class from Slim just do this:
use \Slim\Middleware;
$auth = new HttpBasicAuth();
and autoloader will find the required file automatically for you.
from wp-slim-framework.
Related Issues (9)
- Help starting HOT 10
- CORS Headers and Content-Type settings HOT 3
- DI Container Clash HOT 5
- I'm getting the 404 but can't get an output HOT 3
- Using post data HOT 8
- Ajax CORS HOT 1
- Slim Framework 3 HOT 2
- Using composer to install plugin HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wp-slim-framework.