stdlib

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package stdlib provides the forwarded "bring your own standard library" shims (the README's register_function mechanism). PHP's stdlib is not reimplemented in the VM; instead a curated set of Go functions is registered on a Runtime so transpiled PHP can call them by name. This set is sized to run the minitpl template engine (the T1 compatibility target).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(rt *runner.Runtime)

Register installs the pure (non-filesystem) shims and PHP constants. Use RegisterFS to add filesystem IO bound to a root directory.

func RegisterDatabase

func RegisterDatabase(rt *runner.Runtime)

RegisterDatabase installs the Go database bridge used by PHP via `new DatabaseDriver("driver://dsn")`.

func RegisterFS

func RegisterFS(rt *runner.Runtime, dir string)

RegisterFS installs filesystem IO shims rooted at dir. Reads and writes are confined to that directory tree, mirroring how the upstream engine runs inside its project checkout. Paths from PHP are treated as relative to dir.

Go's fs.FS is read-only, so the engine's writes (fopen/fwrite/mkdir) use the os package against the same root; the runner's include resolution still uses the fs.FS abstraction passed to runner.New.

Types

type DatabaseDriver

type DatabaseDriver struct {
	// contains filtered or unexported fields
}

DatabaseDriver wraps a SQL database connection for PHP scripts.

func NewDatabaseDriver

func NewDatabaseDriver(ctx context.Context, name string) (*DatabaseDriver, error)

NewDatabaseDriver opens a database connection from the named DB_DSN_* env var.

func (*DatabaseDriver) Close

func (d *DatabaseDriver) Close()

Close closes the underlying database connection.

func (*DatabaseDriver) LastInsertId

func (d *DatabaseDriver) LastInsertId(ctx context.Context) (int64, error)

LastInsertId returns the SQLite last inserted row ID.

func (*DatabaseDriver) Prepare

func (d *DatabaseDriver) Prepare(query string) (*DatabaseStatement, error)

Prepare creates a database statement for query.

type DatabaseStatement

type DatabaseStatement struct {
	// contains filtered or unexported fields
}

DatabaseStatement holds a prepared query and bound values for execution.

func (*DatabaseStatement) BindValue

func (s *DatabaseStatement) BindValue(key, value any) error

BindValue binds value to a named or positional query parameter.

func (*DatabaseStatement) CloseCursor

func (s *DatabaseStatement) CloseCursor() error

CloseCursor closes the active result cursor.

func (*DatabaseStatement) Execute

func (s *DatabaseStatement) Execute(ctx context.Context) error

Execute runs the statement and stores the result cursor.

func (*DatabaseStatement) Fetch

func (s *DatabaseStatement) Fetch() (any, error)

Fetch returns the next result row or false when no rows remain.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL