About me
• gong023
• https://github.com/gong023/
• PHP developer of
• #mercari_wakate??
Slide 3
Slide 3 text
I — PHP
Slide 4
Slide 4 text
Interested in rust
Slide 5
Slide 5 text
rust is
• supported by Mozilla
• to replace Firefox engine
• better C++
• golang is better C
Slide 6
Slide 6 text
rust is good because…
Slide 7
Slide 7 text
Safe memory
You can compile errors with dangerous memory operations
Slide 8
Slide 8 text
Safe memory
You can compile errors with dangerous memory operations
Slide 9
Slide 9 text
Modern syntax
• Optional
Slide 10
Slide 10 text
Modern syntax
• Generics & Traits
Slide 11
Slide 11 text
create php-ext by rust
Slide 12
Slide 12 text
Overview
1. Create shared object file by rust
2. Test shared object file by C
3. Link shared object file from php-ext
Slide 13
Slide 13 text
Create .so file by rust
1. cargo new
2. write a function in rust
3. cargo build
• you can get *.so file
Slide 14
Slide 14 text
Test .so file by C
1. Write test code in C
2. Include .so and compile C test code
• Don’t forget to link shared object
• gcc test.c -L SO_PATH -php_ext
Slide 15
Slide 15 text
Link .so file from php-ext
1. Create php-ext by ext-skel
2. Edit config.m4 and configure
• difficult…
Slide 16
Slide 16 text
Link .so file from php-ext
• Edit config.m4
I don’t know why it doesn’t work
Slide 17
Slide 17 text
Link .so file from php-ext
• Edit config.m4
I added a path ignoring errors
Slide 18
Slide 18 text
Link .so file from php-ext
3. Write .h and .c in php-ext
• see references to know more details
4. make && make install
5. Test
Slide 19
Slide 19 text
Advanced
• I tried to export rust-carbon to php-ext
• https://github.com/gong023/rust-carbon
• But I don’t succeed yet.
I don’t know why it doesn’t work