dll will not recignize using pure mode in phpcore
46 posts
• Page 1 of 5 • 1, 2, 3, 4, 5
dll will not recignize using pure mode in phpcore
Hi Guys,
I'm a software developer, I like Object Oriented php, I think it is very powerful, I also love c#. And that it is now dynamic, in part, make it a powerful combination. I'm working on a project, it is php based (more here) and I can't get the .net PhpCore to auto implement it at runtime.
Here is my web.config:
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime targetFramework="4.0" />
</system.web>
<phpNet>
<classLibrary>
<add assembly="WikiLingo" />
<add assembly="mscorlib" />
</classLibrary>
</phpNet>
</configuration>
Here is the command I use to build the php to a dll:
phpc ^
/target:dll ^
/pure+ ^
/lang:CLR ^
/out:WikiLingo.dll ^
/recurse:../wikiLingo\WikiLingo ^
/recurse:../wikiLingo\WikiLingoWYSIWYG ^
/recurse:../wikiLingo\WYSIWYGWikiLingo ^
/recurse:../wikiLingo\Types ^
/skip:../wikiLingo\WikiLingo\Test ^
/skip:../wikiLingo\WikiLingoWYSIWYG\Test ^
/skip:../wikiLingo\WYSIWYGWikiLingo\Test 2>out.log
Here is the output:
https://github.com/wikiLingo/wikiLingo.net
Here is the project I want to show off using wikiLingo in c#:
https://github.com/wikiLingo/wikiLingo.net-examples
Can you help me along? I'd like to take full advantage of the c# dynamic types. The .net dll loads just fine, but it is just too strongly typed. Perhaps I'm missing something. Perhaps you can't mix pure mode and and phpcore?
I'm a software developer, I like Object Oriented php, I think it is very powerful, I also love c#. And that it is now dynamic, in part, make it a powerful combination. I'm working on a project, it is php based (more here) and I can't get the .net PhpCore to auto implement it at runtime.
Here is my web.config:
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime targetFramework="4.0" />
</system.web>
<phpNet>
<classLibrary>
<add assembly="WikiLingo" />
<add assembly="mscorlib" />
</classLibrary>
</phpNet>
</configuration>
Here is the command I use to build the php to a dll:
phpc ^
/target:dll ^
/pure+ ^
/lang:CLR ^
/out:WikiLingo.dll ^
/recurse:../wikiLingo\WikiLingo ^
/recurse:../wikiLingo\WikiLingoWYSIWYG ^
/recurse:../wikiLingo\WYSIWYGWikiLingo ^
/recurse:../wikiLingo\Types ^
/skip:../wikiLingo\WikiLingo\Test ^
/skip:../wikiLingo\WikiLingoWYSIWYG\Test ^
/skip:../wikiLingo\WYSIWYGWikiLingo\Test 2>out.log
Here is the output:
https://github.com/wikiLingo/wikiLingo.net
Here is the project I want to show off using wikiLingo in c#:
https://github.com/wikiLingo/wikiLingo.net-examples
Can you help me along? I'd like to take full advantage of the c# dynamic types. The .net dll loads just fine, but it is just too strongly typed. Perhaps I'm missing something. Perhaps you can't mix pure mode and and phpcore?
- RobertPlummer
- Posts: 37
- Joined: April 7th, 2014, 1:45 pm
Re: dll will not recignize using pure mode in phpcore
Hi Robert,
Thanks for your question.
I've tested wikiLingo and it compiles pretty nice in the pure mode.
The result is a .NET assembly containing PHP types and functions organized in namespaces as it is in PHP.
Note it emits
Resulting assembly can be just referenced within your C# project together with PhpNetCore.dll (and since Phalanger 4.0 PhpNetCore.Parsers.dll). In app.config (or web.config) you can just reference PhpNetClasslibrary and PhpNet* extensions you need.
I'm attaching my sample C# project.
Note/Todo: you can specify
Thanks for your question.
I've tested wikiLingo and it compiles pretty nice in the pure mode.
The result is a .NET assembly containing PHP types and functions organized in namespaces as it is in PHP.
Note it emits
- Code: Select all
[EditorBrowsable(EditorBrowsableState.Never)]
Resulting assembly can be just referenced within your C# project together with PhpNetCore.dll (and since Phalanger 4.0 PhpNetCore.Parsers.dll). In app.config (or web.config) you can just reference PhpNetClasslibrary and PhpNet* extensions you need.
I'm attaching my sample C# project.
Note/Todo: you can specify
- Code: Select all
[assembly: \Export]
class AssemblyInfo{}
You do not have the required permissions to view the files attached to this post.
Jakub Misek │ DEVSENSE s.r.o. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
Re: dll will not recignize using pure mode in phpcore
I've fixed compilation in pure mode with [Export] attribute (see above) and compiled wikiLingo as a reference (attached).
Please feel free to download and reference to your C# project to see whether it is visible in IntelliSense as expected. (it is built against Phalanger 4.0)
Please feel free to download and reference to your C# project to see whether it is visible in IntelliSense as expected. (it is built against Phalanger 4.0)
You do not have the required permissions to view the files attached to this post.
Jakub Misek │ DEVSENSE s.r.o. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
Re: dll will not recignize using pure mode in phpcore
Thanks for your help! I cant' wait to use the parser in .net! Phalanger (and Jakub) rules!
- RobertPlummer
- Posts: 37
- Joined: April 7th, 2014, 1:45 pm
Re: dll will not recignize using pure mode in phpcore
I finally got a chance to try this out, it is now asking for Phalanger v4. Which I do not have and cannot find online. One thing that does work is:
var parser = new WikiLingo.Parser(PHP.Core.ScriptContext.CurrentContext, true);
However, the __construct method isn't called, is this by design? Am I doing something wrong?
var parser = new WikiLingo.Parser(PHP.Core.ScriptContext.CurrentContext, true);
However, the __construct method isn't called, is this by design? Am I doing something wrong?
- RobertPlummer
- Posts: 37
- Joined: April 7th, 2014, 1:45 pm
Re: dll will not recignize using pure mode in phpcore
You are calling internal .ctor which does not invoke __construct method.
You have to use attribute [\Export] to create C# constructor that calls __construct or to call __construct by yourself.
You have to use attribute [\Export] to create C# constructor that calls __construct or to call __construct by yourself.
Jakub Misek │ DEVSENSE s.r.o. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
Re: dll will not recignize using pure mode in phpcore
Would it be at all possible to perform a pull request on wikiLingo, perhaps WikiLingo\Parser, showing how to do this? I think it would really help with the understanding of how to use Phalanger. You could even link to it, for a real world example, as we want to go full steam with .net.
- RobertPlummer
- Posts: 37
- Joined: April 7th, 2014, 1:45 pm
Re: dll will not recignize using pure mode in phpcore
Just a side note, 98% of my work is open source. I wouldn't ask you to do this if it was for personal gain, I want Phalanger to be understood well, on a grand scale.
- RobertPlummer
- Posts: 37
- Joined: April 7th, 2014, 1:45 pm
Re: dll will not recignize using pure mode in phpcore
Can you put "[assembly: \Export]" within comments? Like this:
Or, better yet, can we use PHPDoc's comments, which allow you to build documentation and develop at the same time? PHPDoc is kind of a standard. If we did that, not only would IDE's like phpStorm, and the documentation builder bind to the comments, but also .net.
Here we let PHPDoc know that there is a namespace called "WikiLingo" and that there is a class in it called "Parser". If we utilized those comment, it would really bind Phalanger to php.
- Code: Select all
/**
* Class Parser
* @package WikiLingo
* [assembly: \Export]
*/
class Parser extends Definition {}
Or, better yet, can we use PHPDoc's comments, which allow you to build documentation and develop at the same time? PHPDoc is kind of a standard. If we did that, not only would IDE's like phpStorm, and the documentation builder bind to the comments, but also .net.
- Code: Select all
/**
* Class Parser
* @package WikiLingo
*/
class Parser extends Definition {}
Here we let PHPDoc know that there is a namespace called "WikiLingo" and that there is a class in it called "Parser". If we utilized those comment, it would really bind Phalanger to php.
- RobertPlummer
- Posts: 37
- Joined: April 7th, 2014, 1:45 pm
Re: dll will not recignize using pure mode in phpcore
[assembly: \Export] cannot be put within comments.
Phalanger already contains support for PHPDoc. Internally it is able to parse and process such comments. Generating .NET-like XML documentation has to be done.
Phalanger already contains support for PHPDoc. Internally it is able to parse and process such comments. Generating .NET-like XML documentation has to be done.
Jakub Misek │ DEVSENSE s.r.o. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
46 posts
• Page 1 of 5 • 1, 2, 3, 4, 5
Who is online
Users browsing this forum: No registered users and 12 guests