Dependency Injection (DI) என்பது ஒரு design pattern ஆகும், இதில் ஒரு class அதன் dependencies-ஐ வெளியிலிருந்து (வழக்கமாக constructor மூலம்) பெறுகிறது, அதை தானாக உருவாக்கிற்க வாய்ப்பாக இல்லாமல் இருக்கும்வாறு செய்யப்படுகிறது. நவீன PHP frameworks DI-ஐ பெரிதளவில் பயன்படுத்துகிறது, பெரும்பாலும் ஒரு container-உடன் இது தானாக dependencies-ஐ resolve செய்து inject செய்கிறது — இது loosely-coupled, testable code-க்கு வழிவகுக்கிறது.
DI தீர்க்கும் சிக்கல்
{
;
{
->mailer = ();
}
}
{
{}
}
