php
PHP programming language module.
Example (Extension)
func (m *Examples) Php_Extension(ctx context.Context) error {
_, err := dag.Php().
WithExtensionInstaller(). // This is optional: will be installed automatically
WithExtension("zip").
Container().
WithExec([]string{"php", "-m"}).
Sync(ctx)
return err
}
Example (Composer)
func (m *Examples) Php_Composer(ctx context.Context) error {
_, err := dag.Php().
WithComposer(). // This is optional: will be installed automatically
WithComposerPackage("phpstan/phpstan").
Container().
WithExec([]string{"phpstan", "analyse", "--help"}).
Sync(ctx)
return err
}
Installation
dagger install github.com/sagikazarmark/daggerverse/php@v0.2.0
Entrypoint
Return Type
Php !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
version | String | "latest" | Version (image tag) to use from the official image repository as a base container. |
container | Container | - | Custom container to use as a base container. Takes precedence over version. |
Example
func (m *myModule) example() *Php {
return dag.
Php()
}
Types
Php 🔗
withComposer() 🔗
Install Composer.
Return Type
Php !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
version | String | "latest" | Version (image tag) to use from the official image repository. |
binary | File | - | Custom binary to use. Takes precedence over version. |
Example
func (m *myModule) example() *Php {
return dag.
Php().
WithComposer()
}
withComposerCache() 🔗
Mount a cache volume for Composer cache.
Return Type
Php !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
cache | CacheVolume ! | - | No description provided |
source | Directory | - | Identifier of the directory to use as the cache volume's root. |
sharing | Enum | - | Sharing mode of the cache volume. |
Example
func (m *myModule) example(cache *CacheVolume) *Php {
return dag.
Php().
WithComposerCache(cache)
}
withComposerPackage() 🔗
Install a Composer package globally.
Return Type
Php !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
name | String ! | - | No description provided |
Example
func (m *myModule) example(name string) *Php {
return dag.
Php().
WithComposerPackage(name)
}
withComposerPackages() 🔗
Install a list of Composer packages globally.
Return Type
Php !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
name | [String ! ] ! | - | No description provided |
Example
func (m *myModule) example(name []string) *Php {
return dag.
Php().
WithComposerPackages(name)
}
withExtensionInstaller() 🔗
Install docker-php-extension-installer.
Return Type
Php !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
version | String | "latest" | Version to use from the official repository. |
binary | File | - | Custom binary to use. Takes precedence over version. |
Example
func (m *myModule) example() *Php {
return dag.
Php().
WithExtensionInstaller()
}
withExtension() 🔗
Install an extension using docker-php-extension-installer.
Return Type
Php !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
name | String ! | - | No description provided |
Example
func (m *myModule) example(name string) *Php {
return dag.
Php().
WithExtension(name)
}
withExtensions() 🔗
Install a list of extensions using docker-php-extension-installer.
Return Type
Php !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
name | [String ! ] ! | - | No description provided |
Example
func (m *myModule) example(name []string) *Php {
return dag.
Php().
WithExtensions(name)
}
container() 🔗
Return Type
Container !
Example
func (m *myModule) example() *Container {
return dag.
Php().
Container()
}
withSource() 🔗
Mount a source directory.
Return Type
WithSource !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
source | Directory ! | - | Source directory to mount. |
Example
func (m *myModule) example(source *Directory) *PhpWithSource {
return dag.
Php().
WithSource(source)
}
WithSource 🔗
source() 🔗
Return Type
Directory !
Example
func (m *myModule) example(source *Directory) *Directory {
return dag.
Php().
WithSource(source).
Source()
}
container() 🔗
Return Type
Container !
Example
func (m *myModule) example(source *Directory) *Container {
return dag.
Php().
WithSource(source).
Container()
}
withExec() 🔗
Run a command.
Return Type
WithSource !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
args | [String ! ] ! | - | Arguments to pass to the command. |
Example
func (m *myModule) example(source *Directory, args []string) *PhpWithSource {
return dag.
Php().
WithSource(source).
WithExec(args)
}
withComposerInstall() 🔗
Make sure Composer dependencies are installed.
Return Type
WithSource !
Example
func (m *myModule) example(source *Directory) *PhpWithSource {
return dag.
Php().
WithSource(source).
WithComposerInstall()
}