Forums » Ryzom API suggestions »
API improvements proposal.
Added by LupusMichaelis almost 6 years ago
Hi folks,
I want to propose some improvements to the Ryzom PHP API. So I start and can propose a patch that centralize URL factory. It is just a little refactoring, and a security improvements. I do improve by escape HTTP parameters values, it increase security. So they are some improvements to do to assure security, but it is a first step. I can't test well because I have no Ryzom account, and I can't create one currently (I'm only under Linux, and now with a netbook).
So a bunch of questions :
- will you set up a test server for the contest (tobe able to test character and guild features) ?
- where is the Ryzom Webservices API ? :D
- how to submit a patch ? (with git diff ?)
I don't have an actual idea of application for now. But I would like improve the PHP API first before spend some time on a user tool. I observe the code is very redondant, and it can be reduced to ease maintenance. I'll work at.
And thanks to permit such a contest.
Replies (10)
RE: API improvements proposal. - Added by LupusMichaelis almost 6 years ago
Hi,
I was hoping a response until the WE :'(
I attach the first patch I done, one that centralize URL factoring.
I attach a second patch, that automatize access to Ryzom Webserver.
But for now I am a little stuck. I could deduce XML API from some we can fetch, but i rather prefer a reference to Webservices API. That make my think about the server part of the Ryzom API you released : why it doesn't belong the client sources ?
I hope the work I attach will not go to trash without any eye on it.
url.diff - git diff master (URL handling) (39.5 kB)
object.diff - git diff master (DAO) (53.7 kB)
RE: API improvements proposal. - Added by nimetu almost 6 years ago
seems that you did not use git commit to separate the patches, objects.diff has everything url diff has + some classes. also url.diff has bit more than just url fixes ;-)
git loves commits, so make it happy and commit in few files at a time in logical patches (local repo is yours, do whatever you like with it)
you forgot to include ryzom_config.php ;-)
RE: API improvements proposal. - Added by vl almost 6 years ago
Sorry, I miss your post :/
will you set up a test server for the contest (tobe able to test character and guild features) ?
There's some test characters that you can use if you don't have one http://dev.ryzom.com/projects/ryzom-api/wiki#Testing-Characters
You can create a test character on the normal live server.
where is the Ryzom Webservices API ? :D
I don't understand your question. You see in the wiki that all api are in atys.ryzom.com/api/
how to submit a patch ? (with git diff ?)
The best way to do changes in the php code is to go to github http://github.com/acemtp/ryzom_api/tree/master , create a fork and then commit your changes directly on this fork.
As you can see someone else already fork it http://github.com/acemtp/ryzom_api/network to do some changes.
RE: API improvements proposal. - Added by kervala almost 6 years ago
- where is the Ryzom Webservices API ? :D
Did you mean SOAP webservices ?
RE: API improvements proposal. - Added by LupusMichaelis almost 6 years ago
I was hoping you missed me ;)
(nimetu) The object branch is based upon the URL branch, because it reuse ryzom_url. I like to commit when a feature is done, or after some reordering. I don't want to manage large commit list, it is a hell. I did it in professionnal context with subversion, and it was a nightmare.
Thaks to point me the missing file, I attach the new one.
(vl) No offense ;)
Finally I seen the guild and characters keys. I just not read the documentation further in a first glance.
In the wiki, you document the PHP API. We can deduce HTTP params that is needed from the API source code, but it is hardier to determine the XML API, the DTD or XSD if you prefer. We have to inspect XML results and how they are interpreted in the example.
If we want to start an AJAX project, you prefer a WebAPI documentation rather than a PHP API that have no interest for a standalone project, for example.
I'll maybe fork on github, but I don't like all this social networking things. I prefer to set up and control my own server. It's in my todo list to set up a git server, but I'm very concerned by security issues I can open if I do bad work. So It isn't ready yet.
Thanks for the reply !
Et si vraiment mon anglais craind trop, on peut essayer la version sous-titrée ;)
object.diff - git diff object (Add ryzom_config.php file) (56.6 kB)
RE: API improvements proposal. - Added by nimetu almost 6 years ago
LupusMichaelis wrote:
(nimetu) The object branch is based upon the URL branch, because it reuse ryzom_url. I like to commit when a feature is done, or after some reordering. I don't want to manage large commit list, it is a hell. I did it in professionnal context with subversion, and it was a nightmare.
git is different in svn on commits. you dont need to commit all the changed files, select few with "git add <file1> <file2>" and do 'git commit -m"msg"'
Thaks to point me the missing file, I attach the new one.
tool_registry.php ? ;-) please, just a file this time;-)
also, i think you cant use 'const' outside class and need to use define('RYZOM_HOST', 'atys.ryzom.com'); for example
and in ryzom_dao.php, you should not use 'ryzom_api/' directory as it's already inside it.
... and i dont know if you can move render css/images out from ryzom_api as 'ryzom_api' directory is the api library (example_profile.php does not have copyright header, but ryzom_ui.css does for example)
RE: API improvements proposal. - Added by LupusMichaelis almost 6 years ago
I did patch against the branch I fetched, to ease integration. I attached the patch that contains tool_registry.php. I hope I doesn't miss another one.
I'm sure you can use const keyword outside a class, like you can declare functions that has the same name as a function (I use this to provide a cast function to ease the use of a class). Have a look on the documentation, last example before comments http://us.php.net/manual/en/language.constants.syntax.php
I moved the render directory to reduce the need to put ryzom_api in a public directory. This increase security. It is a proposal, I give you arguments to accept it because I think it is good for the project.
Of course, all alteration and improvements where tests. I didn't commit the tests for registry feature, because it use my personnal framework, and I didn't released it for now.
object_.diff (3.7 kB)
RE: API improvements proposal. - Added by nimetu almost 6 years ago
LupusMichaelis wrote:
I'm sure you can use const keyword outside a class, like you can declare functions that has the same name as a function (I use this to provide a cast function to ease the use of a class). Have a look on the documentation, last example before comments http://us.php.net/manual/en/language.constants.syntax.php
...or by using the const keyword outside a class definition as of PHP 5.3.0
5.3 is too new. Not everyone has upgraded yet ;-) think of all those odd shared hostings people might use (maybe go as low as PHP4 even).
RE: API improvements proposal. - Added by LupusMichaelis almost 6 years ago
Sorry for the lag, I'm doomed with my current job :'(
I don't really care about lazy people, how think PHP is a language, and think the one they installed are ok because it runs. PHP is a template engine, it is an OSS. this two facts implies the next thing : have a lag with the head version equals to lag on hijackers. Numerous bogus and security issues where corrected with the 5.3 version. they are actual behaviour changes between 5.2 and 5.3 (mainly with magic oriented object methods).
I think it is a waste of time to support old versions of PHP, Because you have to fight with old bugs.
And for the PHP 4 version... don't speak about, or Hulk will be a nice rabbit near me ;) (I'm currently studying the migration of a tool from PHP4 to PHP53, it's rock'n'roll).
So said, don't be affraid. I didn't use some tools only available in PHP53 except for the const keyword in global scope, I just missed it was a very close implemented feature. You didn't seen closure or namespace in my code, right ? ;)
I continued to work on my object version of Ryzom API. I home to provide a git commit in the evening. I'm facing some design issues, I need some help to resolve them. If someone would help, he'll be welcome. This API will not be submit to the contest, because I 've not the feeling an API is a « free software applications for Ryzom players », but for developper players.
RE: API improvements proposal. - Added by LupusMichaelis almost 6 years ago
For those people who are interestead by a more object oriented API, I release the draft I'm working on.
(1-10/10)