Integrating PHP5 library into Ionic project using Composer?


#1

I’m working on a project that only has a REST API PHP5 Library and it uses Composer.

I have never touched Composer and avoid PHP if I can. How can I get something like this into an ionic project? As far as I know Node and PHP don’t like each other very much and I don’t see anything online with Composer and Ionic working together?

Is this possible?

Anything out there I should take a look at? or tips or suggestions?


#2

You can’t get something like this into Ionic project.

The Ionic framework is client side application, your PHP REST application is server side application. On the other hand, The Composer is just a PHP application-level package manager, nothing else nothing more.

What you need is a way to connect your Ionic application with your server side REST application. I don’t know which RESTful PHP framework you’re using so I can’t give you server side example.

But if you do know how your REST application routing works you can use this piece of code to communicate between Ionic and PHP REST service:

    var url = 'http://api.themoviedb.org/3/',
      mode = 'search/movie?query=',
      name = '&query=' + encodeURI(moviename),
      key = '&api_key=470fd2ec8853e25d2f8d86f685d2270e';
  
    $http.get(url + mode + key + name).success(function(data) {
  
      cachedData = data.results;
      callback(data.results);
    });

You should also read AngularJS http service documentation: https://docs.angularjs.org/api/ng/service/$http