dreamfactorysoftware / dreamfactory

DreamFactory API Management Platform
https://www.dreamfactory.com
Apache License 2.0
1.55k stars 314 forks source link

Custom Scripts are cut off after 1550 lines !! #101

Closed philicious closed 8 years ago

philicious commented 8 years ago

When uploading a script, its cut off after line 1516 when saving. When pasting a script, its cut off after line 1550 when saving.

This is a major problem we just run into and the dev team cant extend the service any further now !

leehicks commented 8 years ago

You are probably hitting the max limit storage size per script of 65k characters (i.e. stored in 'text'). What scripting language are you writing in? My suggestion would be to split the long script into libraries to include. In V8js case, you can include files directory from the storage/scripting directory in the install. Similarly in other languages.

philicious commented 8 years ago

We are using PHP scripts. Most notably because one can then access DF classes etc. And I'm re-using DFs Redis class aswell as others for manipulating JWT tokens.

Splitting the script would be an option in general. However for us this would involve also splitting swagger defs, re-generating and refactoring client SDKs and their implementation etc etc. So at least 1d of work.

As far as I understand you cannot do "include or require" with PHP services, right ? At least thats what I read somewhere in Wiki or forum.

a15lam commented 8 years ago

@philicious, another work around you can do is that, write most of your PHP code separately in its own class in a separate package. Then include your package in DF via composer. After that you can just simply use your classes in your much smaller php script.

philicious commented 8 years ago

@df-arif thats a great idea actually ! If you guys dont see any feasible fix for the character/line limit ?

df-arif commented 8 years ago

@philicious, as of this moment we do not have any plan to bump that character limit. But either way, if your script is that long then it is better anyway to put them in a proper PHP file using classes and functions rather than storing them as text in db field. This will allow you to maintain your code better, and will save you from lot of headache in the future. Plus, it will easily allow you to put the meat of your script under Git/Other version control. In this way your actual DF script will be very small, much like a simple controller.

This is actually a neat feature of DF PHP scripting. This essentially makes it really easy to RESTify any php application (specially one written in MVC pattern) under DF.

philicious commented 8 years ago

@df-arif yes. absolutely makes sense. scripts started out small but devs did alot work. so its time for refactoring now and doing proper classes :)