Giter VIP home page Giter VIP logo

wp-slim-framework's People

Contributors

botnary avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

wp-slim-framework's Issues

I'm getting the 404 but can't get an output

I have the plugin installed in the correct spot, I've changed the settings for the plugin to nano/api/, and I'm using /%postname%/, for the permalinks. I'm running locally via MAMP. I created a test plugin to play with Slim:

add_action('slim_mapping',function(Slim\Slim $app){
    //here you have access to slim $app and can define routes
    $app->get('slim/api/books/:id',function($bookId)use($app){
    echo 'book';
});

I'm getting the Slim 404 when I pass localhost/nano/api/books/12. I'm hoping to get "book" back. The idea, once I get working is to return json. Right now I just want to return something with my get calls instead of getting the Slim 404 page (I know it's not the WP 404).

Slim Framework 3

Hey,

Love your plugin, any chance it can be upgraded to Slim 3 ?

Thanks

Using post data

Hi, I'm just getting set up with this plugin and I'm wondering how I pass Post data through and then use it from the slim_mapping function.

I'm querying the api with javascript, (specifically Angular):

req = {
    method: 'POST',
    url: CONSTANTS.external.server + '/slim/api/posts',
    headers: {
        'Content-Type': 'application/json'
    },
    data: {
        'abc': '123',
        'def': '456'
    }
}

$http(req).success(function(response, status) {
...

Then in the PHP file, the slim_mapping function looks like:

public function slim_mapping($slim) {
    $context = $this;

    $slim->post('/slim/api/posts', function($data)use($context) {
        $context->addPost($data);
    });
}

private function addPost($data) {
    echo json_encode($data);
}

How do I get hold of the passed data within the data object?

DI Container Clash

I have installed the plugin on a wordpress instance as prescribed. I am using this Slim application in 2 plugins. When I create an object in the DI container in one plugin the container gets overwritten by the container created and used in the other plugin. I can make the index files of the 2 projects available on request. Wouldn't mind a simple example on how to use this slim plugin with 2 other plugins.

Could you advise?

How can I use middleware for authentication?

I'm trying to use this plugin to convert an app made with slim to a wordpress plugin.

However I need a way to protect access to routes and I was using a middleware to check if user is logged in.

So I have added this line:

require_once 'Slim/Middleware/HttpBasicAuth.php';

But I got this error:

Fatal error: Class 'Slim\Middleware' not found in E:\wamp\www\Blog\wp-content\plugins\wp-slim-framework\Slim\Middleware\HttpBasicAuth.php on line 6

It seems that my middleware cannot extends parent class:

namespace Slim\Middleware;

class HttpBasicAuth extends \Slim\Middleware

COuld you help me? I should try another approach? What is the better way to check if user is authenticated to prevent access to routes?

Thanks

Help starting

Hello, I am looking to use Slim with wordpress and another custom plugin I am developing and I am using this plugin you developed here but I have a couple of questions:

Where does /slim/api actually exist that the api routes live on? If my wordpress site is at http://localhost/site/wp/ should I change the setting in the settings page for Slim Framework? Or do I try accessing it at http://localhost/site/wp/slim/api which I have tried but does not work.

Also, where are you putting the code that calls the action for slim mapping? I put my code in my custom plugin and I just want to make sure it is being called with the correct timing.

Thank you in advance for your assistance!

CORS Headers and Content-Type settings

Can we set the HTTP headers through this library? I'm having a fuss getting CORS requests working or content type set to json for the response. Hoping this can accomodate.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.