Can WCS and REST be written and consumed in PHP - php

I am new to php, i have to consume a API written in .NET with REST and WCS as a service provider.
Also the SSO with SAML2 has to be there.
Frankly speaking i have no idea about what is REST and WCS.
While i see that SAML2 is supported in php.
Can somebody help if REST and WCS is supported in PHP?
I ma googling to get basic idea about what it does but could not find how to do it in php.
Please help

RESTful APIs in WCS v7 FEP7 opens up options to build store-websites using any web programming language and on any web framework while taking advantage of enterprise grade business logic in WCS.
I was part of a PoC to use python (Django) as an alternative over a year ago -- it is very easy and works great. Consuming REST service was just two lines of code:
sampleResponse = urllib2.urlopen('<STORE_URL>' + '/<URI>');
sampleJSON = json.load(sampleResponse);
I am sure PHP (SAML2), Ruby (Rails) should all work just as well.
Some things to remember:
WCS support will not extend to custom technologies - so you will need to extend your own support for store front issues.
You will need to separately size and plan for the horse power required to run your favorite runtime.
I suspect that you will most likely miss out on Commerce Composer feature (or at least requires additional customization there).
You may also need to manage SEO differently - not via WCS Management Center.
There may be others.

Related

How to implement Attribute based Access Control (ABAC) in PHP

I just find one framework of AT&T to build ABAC.
This framework use XACML following XML format to create rules. But this framework just implement for Java.
However, I 'm working with PHP and I am using JSON to write rules.
Is my solution correct? May you suggest some frameworks or solutions supporting for PHP?
To complete David's answer regarding AuthzForce: it is open source, XACML 3.0 compliant and provides both a Java API (AuthzForce Core) and REST API for PAP and PDP. So you could use the REST API from your PHP program. The API supports XML and JSON format for both PAP and PDP interfaces. However, we are not using the JSON profile of XACML for PDP. Instead, for the whole API, we are using the mapped convention provided by Apache CXF. Such convention allows automatic translation from XML (more precisely the internal XML-derived model used in the implementation code) to JSON, and vice versa automatically.
EDIT (2018-02-26):
AuthzForce Core and Server now both support the standard JSON Profile of XACML for the PDP. AuthzForce also provides a minimal RESTful PDP based on the Core, either packaged as a Spring-boot app, or simply the JAX-RS implementation for reuse in any JAX-RS framework.
The AT&T framework was an R&D framework designed by AT&T a few years ago and then released to Apache. According to github, it is still active. I am not aware of any commercial use of the product (though I suspect AT&T use it themselves).
The three main frameworks used out there are:
WSO2 Balana. This is an open-source Java PDP. It is also bundled as part of WSO2 Identity Server. Most open source users use Balana.
SunXACML: this is the original XACML 3.0 implementation. It is pretty old but sturdy (it's been around for 10 years or so). It is also open-source and Java.
Axiomatics Policy Server. This is a commercial solution (disclaimer: I work for Axiomatics). It is the most prevalent commercial solution out there. It is also implemented in Java but supports integration for PHP too.
You can find this information on XACML's wikipedia page. There is another interesting engine called AuthZForce but I have little experience with it.
All these engines, AFAIK, use XACML's XML format to store policies. You claim you need JSON. There is no Policy profile of XACML in JSON. There was a question on the topic which you can read here.
Given The Axiomatics Policy Server is exposed as a JSON API, you can use it to integrate with PHP. Other engines probably have a similar approach. If you use Amazon AWS, you can request a copy of the Axiomatics Policy Server AMI.
ABAC is technology-neutral meaning it is not specific to Java, Ruby, .NET, PHP or any other language. What the PDP engine is written in is irrelevant to what your application is written in so long as you can integrate the two together.
I hope this helps,
David.
The TYPO3 Access Control component implements ABAC supporting a simple but expressive access control policy language based on Jiang, Hao & Bouabdallah, Ahmed (2017) and is written in PHP.
Checkout the JSON schema to get an quick impression about the access control policy language. The component is lean and flexible. It's neither opinionated about the format nor about the expression language of the policy language. For example you could use YAML and Symfony expression language. As such a policy could look like this:
description: 'Root policy set.'
algorithm: highestPriority
policies:
Admin:
target: 'hasAuthority("typo3:security:principal:admin")'
description: 'Administrator policy'
priority: 100
rules:
-
effect: permit
Default:
description: 'Deny everything per default.'
rules:
-
obligation:
deny:
Feedback: ['Access denied.']

Laravel5 (PHP) or SailsJS (node.js)?

Actually, I am working on a project with Laravel5 (laravel.com)
someone who is working on another project with SailsJS (sailsjs.org) asked me why I am still using PHP. I should work with nodejs (sails), because PHP would be a language would be going to die.
Well, what's better to use for the future.
Both are MVC frameworks
on both you can code views with Jade (see jade-lang.org)
on both you can use any database.
on both you can easily install modules (composer / npm for the backend), bower for the frontend
What's better - and an important aspect - which framework creates responds faster?
As a technical guy, i would suggest you to use sails over laravel. Its not because PHP is going to die(and it will not happen).
As far as i know, anything built on javascript would be faster.
There are lot of advantages in sails like sockets are very easy to implement so on.
When it comes to disadvantage, its only with DOCUMENTATION. For a beginner, it would become little difficult to grasp all the things.
From PHP (Synchronous) to sails(Assynchronous), it will take some time to get familiar with sails.
Make sure you understand the basics of node.js very well before you start with sails.
For more references, see this , this and this
PHP is never going to die, Choosing a technology stack all depends on application & available resource, If you have expertise in php then you will obviously take longer time building app in nodejs/sails.
I have worked on both frameworks (sailsjs & larave 5.2) and for my new project i will go with laravel because:
Laravel is pretty mature framework (was founded in 2011 and has 9K contributors)
It got builtin support for most of things like migraters, seeders, queuing system and templates.
Documentation is very good.
lots of 3rd party integration, you can integrate it with s3-buckets, dropbox any email service provider and backup services in few minutes. complete list of integrations
Disadvantage of laravel:
Socket support is poor, but you can do socket part in nodejs, and can
bridge that using REST APIS.
Mongodb support is not good.

Which web application framework to use with existing database? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
My company wants to start mobile web application development, as an addition to our own ERP software. We do not have any expert knowledge about this, that is why I have to research which tools/frameworks/languages we are going to use.
We already have an existing database, and want to be able to quickly build an extra simple web app, to deploy some handy mobile functionality for our customers. For example, we want to start with making the agenda in our software available for mobile/tablet.
We want to set it up like the following:
we host the web application internally
the web application remotely accesses to the customer's database (Advantage Database Server, can be query'd remotely through JSON), which can also be multiple customer's databases
We develop our desktop software in Delphi, and therefore are not experienced web developers. A framework should meet the following needs:
IDE available, maybe some other handy tools
Preferably small learning curve
Good documentation/support
suited for mobile web development
suited for simple and small web apps, there won't be any need for developing web apps with lots of functionality (most likely aimed at being able to perform two or three tasks)
We will be making a choice for a direction for the coming years, so any possible guarantee about the framework being continued for a period of time is also nice.
So far I've learned that we most likely won't need an ORM, since we definitely won't change our database structure to suit the web app.
So my question is:
which frameworks should I take a closer look at, and which can already be ruled out?
BTW: I'm not looking for an answer for a designer's framework such as Sencha Touch, JQueryMobile etc.
Thanks in advance!
We develop our desktop software in Delphi, and therefore are not experienced web developers.
In that case, I think you are solving the wrong problem:
Hire a team lead who is (even if it is just as a contract role for the first project or two). You need to have someone on board who is aware of all the technologies involved (HTML, JavaScript, CSS, HTTP, SSL) and how to use them appropriately and securely.
Let them determine what tools the team uses — they will have to support the team as it learns to use them.
(If I was going to name a framework, it would be Dancer as that meets most of your requirements)
I have experience with many PHP frameworks (Zend, CakePHP, Kohana, CodeIgniter, Akelos and 2 in-house solutions). Also having some experience with Python's Django framework and lot's of experience with PHP Yii framework, I can recommend Yii both hands up. Even though every robust framework has quite some learning curve, I can say that Yii was the easiest to learn and I was left with most pleasure developing with it.
It is PHP 5 framework, event driven, with support for callback closures and other PHP 5.3 features.
Exceptionally well documented
Extremely fast, due to the fact its component based - you can use only few basic components that you need, also it doesn't have hundreds of abstractions like in Zend so you won't get lost in object references
Very friendly community - I have never been left without an answer if I explain my question well
You can use Active Record ORM models but this is absolutely your own choice. You can go with its DAO (basically PDO wrapper) and write plain SQL. I would rarely do that. Using AR in most cases can save you lots of work and at least in Yii it wouldn't mind any kind of table schema. So I don't see a valid reason to not use AR except for complex queries.
It is themeable, both simple views and widgets/modules - I've been amazed how easy it is to make a mobile version of a website just by creating a new theme.
It has great support of i18n - its easy to make a multilingual web applications if at some point you need it
Both Eclipse PDT and Netbeans 7 for PHP are great web development tools that have some additional support for Yii (though with them it was easy to develop such web apps even before their Yii support).
It's comes with jQuery for it's core widgets for common tasks, yet you are free to use any JS framework you prefer (you probably would never use most of those core widgets for mobile too much anyway).
There is even more to say, but go ahead and check its website:
http://www.yiiframework.com/
No matter what framework you choose, most of the work for a successful mobile web app is left for you.
Check out web2py, as it is probably one of the easiest to set up, learn, and use. You can use it with any IDE or editor, but it also includes its own web-based IDE and administrative interface for application management and basic editing (see demo). It has great documentation, and there's a very active and response mailing list if you need any help.
Rather than an ORM, it includes a database abstraction layer (DAL), which is a little closer to SQL and should provide some extra flexibility (it also includes some scripts to auto-generate web2py DAL models for existing MySQL and PostgreSQL database tables). It includes jQuery, and there's a plugin for jQuery Mobile.
web2py has been around for about four years and is still very actively developed, with new releases every month (yet it has maintained backward compatibility of the documented API since the beginning, and will continue to do so).
InfoWorld recently published a review of six Python web frameworks, including web2py:
Overview/Comparison
web2py
In-Depth

Developing an application server: django vs. zend vs. cakephp vs. codeigniter vs. other

I'm trying to develop an application server that will deliver content to a core group of websites, as well as provide third party services to other websites that also want to use this content. The app server will be hosting web services for these core + 3rd party websites. Authentication and all that comes into play. The data itself will consist of millions of records.
These records will come from a variety of sources: APIs, RSS feeds, REST services, etc. This app server will essentially collect this data on a routine basis, and update the database with this new information. This data will then be shared via some sort of web service (most likely REST) to the core websites and 3rd party websites.
FYI, I'm making a distinction between core sites and 3rd party websites because there will be different access levels, i.e. a core website will have more access than a 3rd party website.
All that said, I'm trying to make the best decision on which framework to use. At the risk of losing all credibility, I currently have a ton of this code written as a wordpress plugin. What started as a one-time site evolved into several sites, and some homebrew hacking to make my outdated infrastructure work across multiple sites.
I'm looking to migrate all of this to a new application server, with a solid framework.
Since everything is written in PHP, obviously I'm tempted to do the migration in PHP. However, I'm considering Python because of its powerful ability to manipulate data. I don't know if it's worth the hassle, though, of rewriting a lot of code in Python.
Could anyone give me some tips on what I should do? I'm really looking to clean up a big mess more than anything, and would like a framework to encourage some solid programming conventions.
All of the frameworks that you mentioned are capable. Pick one in the language that you know the best and use that.
I agree with #gpojd's opinion. All of them that you mentioned are fully capable.
However, it looks like they are too powerful for your job. Because they are all full-stack MVC-like web frameworks shipped with ORM, Template engine, URL redirections and i18n supports.
So, I suggest you to use more lighter/thinner frameworks. and if you don't mind choosing any programming languages, please check out the below frameworks.
Python
Werkzeug : http://werkzeug.pocoo.org/
Javascript
node.js : http://nodejs.org/
with Stylus framework : http://expressjs.com/

How to write a REST API?

I'm writing an iPhone app as a hobby project and it will need a web service to provide it with data. It's not very different from what I do at work, but at work I only write views and controllers. Someone else is responsible for writing the model and usually the clients provide the web service.
I have done some web programming before, back when everyone were using MySQL and PHP, so my skills are a bit outdated, but I'm confident that I would be able to pull it of using the techniques I already know. However, I don't want to waste my time using obsolete tools. I've figured out that the state of the art would be to write a REST API. I was thinking that there should be some pretty good frameworks out there that pretty much just gives you a REST API with CRUD functionality as soon as you've defined a model.
I guess my question is: What would be the fastest way to get a REST API up and running? I really just want to focus on writing the iPhone app and not spend too much time on this API. It would be great if I could get web administration and revision history too. I should also add that the API isn't supposed to be public, so support for authentication would be great as well.
Just to be clear. I wouldn't mind a PHP framework. In fact it could possibly be better since I know that my current hosting supports it.
EDIT:
The links below which apparently were good for 3 years are no longer working so I went and found a couple of new tutorials that I think are going to stick around for a while. These are on the Ray Wenderlich site, a very well respected ios dev tutorial site. The first article actually references the broken links below but it is complete within itself:
How To Write A Simple PHP/MySQL Web Service for an iOS App
and the second one has a little twist to it. It used parse.com on the backend and AFNetworking. Both of which are quite excellent.
How To Synchronize Core Data with a Web Service – Part 1
I have fixed the broken links below by finding the articles in the way back machine. People seem to like the links so I will keep them. The links above should provide more food for thought.
I am doing exactly the same thing with my iphone app. I found this article on building a RESTful API in PHP:
https://web.archive.org/web/20130910164802/http://www.gen-x-design.com/archives/create-a-rest-api-with-php/
and there is also a followup article here:
https://web.archive.org/web/20130323001500/http://www.gen-x-design.com/archives/making-restful-requests-in-php/
with a link to source code at the bottom of the article.
I have programmed a REST API in ZEND Framework using the Zend_Rest_Controller, on the iPhone I used ASIHTTPRequest. My experience with both where good. At the beginning I had some trouble setting up ZEND and connecting it to mySQL, but once I figured out how to do it I was able to write the API very quickly. I can share more information with you if you have any further questions.
EDIT: There seems to be no official documentation on Zend_Rest_Controller. This link describes how to use it to create your API. You simply have to disable rendering in the init() of your subclass and implement the methods for each REST call.
Just to let you know:
I ended up using Ruby on Rails.
EDIT: Since this answer has been downvoted for not providing the reason behind choosing Ruby on Rails and also no instructions on how to write a REST API with it, I thought I would give you my motivation and some simple instructions.
I started reading a book about Ruby on Rails and realized that all I needed to do was to use scaffolding and I got a JSON REST API for free.
Here's a good guide to get you started: http://guides.rubyonrails.org/getting_started.html
When you have your Ruby on Rails environment up and running, creating your REST API isn't harder than running:
$ rails generate scaffold Post name:string title:string content:text
(Example from the above link.) I also found that Rails is very easy and free to deploy to heroku, which meant that I didn't have to pay for hosting for my very basic, low traffic, REST API. There are many other reasons why I am very happy to work with Ruby on Rails, but that's beyond the context of this question.
I followed a quite simple tutorial for creating RESTful APIs with PHP:
Corey Maynard - Creating a RESTful API with PHP
The main concept includes:
one abstract class that handles the parsing of the URI and returning the response, and
one concrete class that consists of just the endpoints for the API.
What about Python?
I'd use Python, Django and Piston.
I'd generate Django models from your
existent DB using inspectdb.
Add the Django admin to your models.
Add Django Piston to your app.
Profit.
With no experience with Python or Django probably it'll take you a day to develop this solution and all code is unit tested and proved to work.
If you want to use PHP I recommend using the CodeIgniter framework with Phil Sturgeon's REST server:
http://net.tutsplus.com/tutorials/php/working-with-restful-services-in-codeigniter-2
https://github.com/philsturgeon/codeigniter-restserver
Checkout the following PHP class that follows MVC.
http://www.phpclasses.org/package/5080-PHP-Implement-REST-Web-services-servers.html
Hope this helps.
If you already know PHP, there's nothing wrong with a PHP/MySQL backend. You can send all responses in iPhone-compatible plist xml format, and instantly turn the response into a NSDictionary/NSArray/NSNumber data structure with this short snippet of code:
NSString *response = [request responseString];
NSData* plistData = [response dataUsingEncoding:NSUTF8StringEncoding];
NSPropertyListFormat format;
NSString *errorStr;
NSDictionary* plist = [NSPropertyListSerialization propertyListFromData:plistData
mutabilityOption:NSPropertyListImmutable
format:&format
errorDescription:&errorStr];
I also use the ASIHTTP package for forming URLs, sending asynchronous requets, and receiving the responses, I highly recommend it:
http://allseeing-i.com/ASIHTTPRequest/
You should use whatever languages you are comfortable with for the web service. Any language that can formulate REST responses to requests is fine.
That said, if you want to get something running quickly, I suggest using Python on Google App Engine. It's free and you can use Java instead of Python if you so desire. App Engine supports authentication using OpenID and/or Google Accounts (not sure if they're mutually exclusive) so that should make things easier to code.
As far as making the requests on the iOS device, I suggest using ASIHTTPRequest.
Another option is restSQL, an ultra-lightweight persistence framework. See http://restsql.org. It supports MySQL and PostgreSQL and runs in a standard Java EE container, e.g. Apache Tomcat.
restSQL is a very unconventional data access layer. restSQL is not an object-oriented view of the database. It presents flat or hierarchical "views" of relational database tables. These views are query-able and updatable through a simple REST-based HTTP or Java API. The HTTP interface is based on REST principles, which use HTTP’s built-in features, rather than abstracting away from them.
You want a 'REST API with CRUD functionality' and that's exactly restSQL's sweet spot. You could do this with no code. Simply define your SQL Resources via XML files and start doing HTTP calls against them with full CRUD capability.

Categories