Reputation: 6172
After this question I found a good (up to date) example to follow here. I successfully got PHP.Core libraries working in VS but still having problems finding my php classes.
The tutorial is simple enough however
dynamic phpObj = [email protected]();
never finds my php class. I have tried with the example file default.php (classname: PhpClass) and with my own php classes which are similar but have a different name.
What am I missing here? I have tried the option
Project Properties>Package/Publish Web>Items to deploy>all files in project
but that didnt help. Currently I have my php classes just under the project as seen below
The error I get just says it cant find the class:
Using ILSpy here is the main snippet of code for CurrentContext
result = (((ScriptContext)CallContext.GetData("PhpNet:ScriptContext")) ?? ScriptContext.CreateDefaultScriptContext());
This is the line of code that is used to find the php classes (AFAIK).
Upvotes: 0
Views: 376
Reputation: 1050
You have to include your php files into the PHP context first ... In Web App, to 'simulate' php lifecycle properly, do following:
using (var request_context = RequestContext.Initialize(ApplicationContext.Default, HttpContext.Current))
{
var context = request_context.ScriptContext;
context.Include("default.php", false);
// now the declarations declared by default.php are available in context.
// do anything with PHP objects here
}
Upvotes: 1