Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/Tools/PHP/PHP Extension List
Function:
Required plugins for this example: MBS Tools Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Tools/PHP/PHP Extension List
This example is the version from Tue, 23th May 2016.
Project "PHP Extension List.rbp"
FileTypes
Filetype text
Filetype all
End FileTypes
Class Window1 Inherits Window
Control EditField1 Inherits TextArea
ControlInstance EditField1 Inherits TextArea
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() dim f as FolderItem // select a file from extension folder f=GetopenFolderItem("all") if f<>Nil then 'p.out="" '// dl wants just the name? 'if p.run("ini_set ('track_errors', true); dl('"+f.name+"'); echo $php_errormsg;") then 'MsgBox "Loaded extension"+EndOfLine+EndOfLine+f.name 'else 'MsgBox "Failed to load extension"+EndOfLine+EndOfLine+p.out 'end if dim n as Boolean dim path as string = f.ShellPath // better NativePath or UnixPathMBS here! n = p.LoadExtension(path) if n then MsgBox "Loaded extension" else MsgBox "Failed to load extension." end if update end if End EventHandler
End Control
EventHandler Sub Open() dim f as FolderItem if TargetWin32 then f=FindFile("php5ts.dll") elseif TargetMachO then f=FindFile("libphp5.mac.dylib") elseif TargetLinux then if Target64Bit then f=FindFile("libphp5.linux64.so") else f=FindFile("libphp5.linux32.so") end if else MsgBox "Unsupported Platform." quit end if if not PHPMBS.LoadLibrary(f) then MsgBox "Failed to load php library." end if p = new MYPHP if p.Inited then update PushButton1.Enabled=True else MsgBox "Failed to initialize." end if End EventHandler
Function FindFile(name as string) As FolderItem // Look for file in parent folders from executable on dim parent as FolderItem = app.ExecutableFile.Parent while parent<>Nil dim file as FolderItem = parent.Child(name) if file<>Nil and file.Exists then Return file end if parent = parent.Parent wend End Function
Protected Sub update() p.out="" call p.Run "print_r(get_loaded_extensions());" EditField1.text=ReplaceLineEndings(p.out,EndOfLine) End Sub
Property Protected p As MyPHP
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
Function FindFile(name as string) As FolderItem // Look for file in parent folders from executable on dim parent as FolderItem = app.ExecutableFile.Parent while parent<>Nil dim file as FolderItem = parent.Child(name) if file<>Nil and file.Exists then Return file end if parent = parent.Parent wend End Function
End Class
Class MYPHP Inherits PHPMBS
EventHandler Sub LogMessage(message as string) MsgBox message End EventHandler
EventHandler Sub Write(data as string) out=out+data End EventHandler
Property out As string
End Class
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS Tools Plugin.




Links
MBS Xojo blog