Xuanwo commented on code in PR #2782:
URL: 
https://github.com/apache/incubator-opendal/pull/2782#discussion_r1284982115


##########
bindings/php/src/lib.rs:
##########
@@ -15,14 +15,165 @@
 // specific language governing permissions and limitations
 // under the License.
 
+use std::collections::HashMap;
+use std::str::FromStr;
 use ext_php_rs::prelude::*;
-use opendal::{EntryMode, Metadata};
+use ext_php_rs::{exception::PhpException, zend::ce};
+use ext_php_rs::convert::FromZval;
+use ext_php_rs::flags::DataType;
+use ext_php_rs::types::Zval;
+use ::opendal as od;
 
-#[php_function]
-pub fn debug() -> String {
-    let metadata = Metadata::new(EntryMode::FILE);
+#[php_class(name = "OpenDAL\\Operator")]
+pub struct Operator(od::BlockingOperator);
 
-    format!("{:?}", metadata)
+#[php_impl]
+impl Operator {
+    pub fn __construct(scheme_str: String, mp: HashMap<String, String>) -> 
PhpResult<Self> {
+        let scheme = 
od::Scheme::from_str(&scheme_str).map_err(format_php_err)?;
+        let op = od::Operator::via_map(scheme, mp).map_err(format_php_err)?;
+
+        Ok(Operator(op.blocking()))
+    }
+
+    /// Write bytes into given path.
+    pub fn write(&self, path: &str, content: String) -> PhpResult<()> {

Review Comment:
   Maybe we need to use 
https://davidcole1340.github.io/ext-php-rs/types/binary.html?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to