Multi Script Assembly
Multi Script Assembly (MSA), also called as Script Library, is an assembly containing more PHP scripts precompiled in PHP standard mode. This assembly contains compiled PHP scripts organized in namespaces named by the single script relative path.
Simply the compilation of PHP scripts into DLL (e.g. phpc.exe /target:dll /root:. /recursive:. /out:msa.dll) results in MSA. This precompiled assembly can be used then in other .NET projects.
Multi Script Assembly is created whenever user builds PHP scripts in legacy mode (default) as a DLL (/target:dll).
phpc /target:dll /root:. /recurse:. /out:bin/msa.dll
Scripts from precompiled ScriptLibrary can be used then easily in your projects. You can include scripts in PHP language or in your C# project. To setup script library into Phalanger compiler&runtime, add following configuration into your .config file:
<phpNet> <scriptLibrary> <add url="bin/msa.dll" /> <!-- or --><add assembly="msa, Version=126.96.36.199" /> </scriptLibrary> </phpNet>
This will load the script library into the Phalanger compiler&runtime. You can then include scripts from precompiled assembly msa.dll like as they would be on your file system.
In PHP project
Simply setup your script library as it is described above and use standard include statement to include scripts from script library. Note scripts in script libraries has priority over scripts on file system.
In C# (and any other .NET language) project
Setup your script library as it is described above. Then you can include scripts into Phalanger runtime, this will execute the script, declare functions and classes and initialize global variables that are used within the script. Example follows:
var context = PHP.Core.ScriptContext.CurrentContext; // Phalanger execution context (note: thread static) context.Include("file.php", false); // run the script from script library // use context to obtain local variables/constants/functions/types/...