PHP code example of isaacdew / industry

1. Go to this page and download the library: Download isaacdew/industry library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

isaacdew / industry example snippets


MenuItem::factory(5)->create();

class RecipeFactory extends Factory {
    // ...

    public function configureIndustry(Industry $industry)
    {
        $industry->setConfig([
            'provider' => Provider::OpenAI,
            'model' => 'gpt-5'
        ]);
    }
}

Recipe::factory()
    ->tapIndustry(
        fn (Industry $industry) => $industry->setConfig([
            'provider' => Provider::OpenAI,
            'model' => 'gpt-5'
        ])
    )
    ->create();

class MenuItemFactory extends Factory
{
    use WithIndustry;

    protected $prompt = 'Suggest menu items for an italian restaurant.';

    public function definition(): array
    {
        return [
            'name' => $this->industry->describe('The name of the menu item.'),
            'description' => $this->industry->describe('A description of the menu item.'),
            'calories' => random_int(100, 500),
            'price' => $this->faker->randomFloat(2, max: 50)
        ];
    }
}

public function definition(): array
{
    return [
        'name' => $this->industry->describe('The name of the menu item.')
            ->fallback($this->faker->words()),
        'description' => $this->industry->describe('A description of the menu item.')
            ->fallback($this->faker->sentence()),
        'calories' => random_int(100, 500),
        'price' => $this->faker->randomFloat(2, max: 50)
    ];
}

use Isaacdew\Industry\Industry;

MenuItem::factory()
    ->tapIndustry(fn (Industry $industry) => $industry->useCache(false))
    ->make();


$industry->setConfig('cache.lazy_load_until', 50);

use \Prism\Prism\Structured\PendingRequest;

//...

public function configureIndustry(Industry $industry)
{
    $industry->beforeRequest(function (PendingRequest $prismRequest) {
        // Enable OpenAI strict mode
        $prismRequest->withProviderOptions([
            'schema' => [
                'strict' => true
            ]
        ]);
    });

    return $this;
}
bash
php artisan vendor:publish --tag="industry-config"
bash
php artisan vendor:publish --tag="prism-config"