- How do I install johnlui/aliyun-oss in a Laravel app?
- Install it with Composer using composer require johnlui/aliyun-oss, which also pulls Alibaba Cloud's official aliyuncs/oss-sdk-php transitively. On Laravel 5.5 and later the service provider and AliyunOSS facade are auto-discovered; on older versions you must add them manually to config/app.php. After that, publish the package config and add your bucket credentials to .env.
- Does johnlui/aliyun-oss work with the Storage facade in config/filesystems.php?
- The package description markets it as an oss disk you register in config/filesystems.php and use through Laravel's Storage facade. However, the code-level evidence in some versions shows a facade-style API instead, such as AliyunOSS::boot()->setBucket(), uploadFile(), uploadContent(), getFile(), deleteFile(), listFiles(), and getUrl(). Verify which style your pinned version actually ships before designing around Storage::disk('oss') calls, since it changes both integration cost and lock-in.
- Which Laravel and PHP versions does johnlui/aliyun-oss support?
- The package originates from the Laravel 5.x era and its composer.json constraints should be checked against your actual PHP and Laravel versions before adoption. Because the wrapper has very low ecosystem validation, testing it against your exact stack in a staging environment is strongly advised. If the constraints block a modern Laravel release, the wrapper is small enough to fork or replace with the underlying SDK directly.
- How do I configure the Aliyun OSS bucket, endpoint, and credentials?
- Configuration covers the bucket name, the endpoint or region, an AccessKey ID and secret, and optionally a custom domain or CDN host for URL generation. Keep the credentials in .env rather than committed config, and use a least-privilege RAM sub-user scoped to the specific bucket instead of an account-level key. Also confirm the bucket ACL matches your intent, since public-read buckets will expose every object stored in them.
- How do I upload and delete files on Aliyun OSS from Laravel?
- With the Filesystem adapter you use familiar calls like Storage::disk('oss')->put($path, $contents) and Storage::disk('oss')->delete($path). With the facade API you call AliyunOSS::boot()->setBucket($bucket)->uploadFile($path, $file) for uploads, uploadContent() for raw strings, and deleteFile() to remove objects. Existence checks and listings are handled through methods such as hasFile() or listFiles() depending on the version.
- How do I generate a public URL or CDN domain for a file stored in OSS?
- The wrapper exposes a getUrl() style method that builds an object URL, and the configuration supports a custom domain or CDN host so generated links point at your own edge domain instead of the raw OSS endpoint. For private buckets you need signed, expiring URLs, which may require calling the underlying OSS SDK directly. Always store object keys, not full URLs, so you can switch domains later without rewriting data.
- Does johnlui/aliyun-oss support multipart uploads, signed URLs, or STS temporary credentials?
- Not reliably out of the box. Multipart upload, signed upload and download URLs, STS temporary credentials, server-side encryption, lifecycle rules, image processing, and upload callbacks are typically not surfaced by such a thin wrapper. The mitigation is that the official aliyuncs/oss-sdk-php is installed transitively, so any missing capability is reachable by mixing SDK calls behind your own adapter.
- Is johnlui/aliyun-oss actively maintained and safe for production?
- It has roughly 488 GitHub stars but zero Composer dependents, which signals limited real-world validation and a real risk of drift from the upstream SDK and newer Laravel releases. The small surface area works in your favour: the wrapper is readable in minutes, so forking it or swapping in the SDK is cheap. Before production, review credential handling and logging for key leakage and pin a specific tag rather than tracking the default branch.
- How can I test OSS uploads in Laravel without calling Alibaba Cloud?
- Hide the package behind an internal FileStorage or ObjectStorage interface injected as a singleton, then bind a local-disk implementation during tests so your suite never authenticates against Aliyun. For a short smoke test, run against a dedicated non-production bucket with a restricted RAM user to validate endpoint, ACL, and generated URL shape. This same interface is also your fallback path if the package becomes unmaintained.
- What are the alternatives to johnlui/aliyun-oss for Aliyun OSS in Laravel?
- Common options are a Flysystem-based OSS adapter that registers as a proper Laravel disk, or using aliyuncs/oss-sdk-php directly behind your own adapter class. If your roadmap requires multi-cloud or storage portability, an S3-compatible abstraction layer is worth evaluating instead of an Aliyun-specific wrapper. Whichever you choose, keep storage calls behind a single internal contract so the decision stays reversible.