// New initializes a PHP engine instance on which contexts can be executed. It // corresponds to PHP's MINIT (module init) phase. func New() (*Engine, error) { ptr, err := C.engine_init() if err != nil { return nil, fmt.Errorf("PHP engine failed to initialize") } return &Engine{engine: ptr, contexts: make([]*context.Context, 0)}, nil }
// New initializes a PHP engine instance on which contexts can be executed. It // corresponds to PHP's MINIT (module init) phase. func New() (*Engine, error) { ptr, err := C.engine_init() if err != nil { return nil, fmt.Errorf("PHP engine failed to initialize") } e := &Engine{ engine: ptr, contexts: make([]*Context, 0), receivers: make(map[string]*Receiver), } return e, nil }
func init() { ptr, err := C.engine_init() if err != nil { panic("PHP engine failed to initialize") } e := &Engine{ engine: ptr, } runtime.SetFinalizer(e, func(e *Engine) { C.engine_shutdown(e.engine) }) engine.Register("php", e, []string{".php"}) }
// New initializes a PHP engine instance on which contexts can be executed. It // corresponds to PHP's MINIT (module init) phase. func New() (*Engine, error) { if engine != nil { return nil, fmt.Errorf("Cannot activate multiple engine instances") } ptr, err := C.engine_init() if err != nil { return nil, fmt.Errorf("PHP engine failed to initialize") } engine = &Engine{ engine: ptr, contexts: make(map[*C.struct__engine_context]*Context), receivers: make(map[string]*Receiver), } return engine, nil }