Installation Add the package via Composer (if still functional):
composer require antwebes/chatea-common
Note: Due to the last release being in 2015, verify compatibility with your Laravel version (likely pre-5.x).
Locate Core Classes
Browse the package’s src/ directory (or vendor/antwebes/chatea-common/src/) for:
BaseModel.php)SerializableInterface.php)ArrayableTrait.php)First Use Case Extend a base model in your Laravel app:
use Antwebes\Common\BaseModel;
class User extends BaseModel
{
// Inherits common methods like `toArray()`, `serialize()`
}
Model Standardization
BaseModel to enforce consistent behavior (e.g., toArray(), serialize()) across all Eloquent models.class Post extends BaseModel
{
protected $fillable = ['title', 'content'];
// Automatically gains `toArray()` via trait.
}
Interface Adoption
SerializableInterface for custom serialization logic:
class ApiResponse implements SerializableInterface
{
public function serialize(): string
{
return json_encode($this->toArray());
}
}
Trait Composition
ArrayableTrait + JsonSerializableTrait) in custom classes:
use Antwebes\Common\Traits\{ArrayableTrait, JsonSerializableTrait};
class ExportableCollection
{
use ArrayableTrait, JsonSerializableTrait;
}
AppServiceProvider:
$this->app->bind(
Antwebes\Common\Interfaces\LoggerInterface::class,
App\Services\CustomLogger::class
);
config/common.php) and adapt to Laravel’s binding system.Deprecated Laravel Features
Model::boot() static methods (use booted() in Laravel 5+).str_limit(); use Str::limit()).Namespace Collisions
Antwebes\Common; ensure no conflicts with your app’s App\Common or similar.Static Methods
BaseModel (e.g., BaseModel::find()). Use dependency injection instead.Trait Overrides
If methods like toArray() behave unexpectedly, check for:
Arrayable interface taking precedence.Serialization Issues
Implement SerializableInterface explicitly if serialize() fails:
public function serialize(): string
{
return json_encode($this->attributesToArray());
}
Custom Traits
Extend existing traits (e.g., ArrayableTrait) by publishing them to your app:
php artisan vendor:publish --provider="Antwebes\Common\CommonServiceProvider"
Note: Verify if the package supports publishing.
Interface Implementations
Override default implementations (e.g., SerializableInterface) in child classes for project-specific logic.
Legacy Compatibility For Laravel 5/6/7/8/9, wrap static calls in a facade or service container binding:
facade('common', Antwebes\Common\Facades\CommonFacade::class);
How can I help you explore Laravel packages today?