Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7814959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:22:08+00:00 2026-06-02T05:22:08+00:00

All my PHP is Object Orinted and I want to use dependency injection for

  • 0

All my PHP is Object Orinted and I want to use dependency injection for all dependencies ( i.e. classes that need other classes to work ). Is this O.K?

I think I posted to much information to be readable…but if you want specifics there are here.

Also, if this does not over-complicate the problem, can I use the Factory Pattern for all dependency injection? – Specifics are in the link above.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T05:22:09+00:00Added an answer on June 2, 2026 at 5:22 am

    Well, yes.

    The whole point of dependency injection is abstraction, give the function/method/object/class what it needs, and have it work it out inside of it. A factory for generating objects and variables to pass for DI is fine.

    For instance:

    public function pdo_select(PDO $pdo_connection, $table, $where_condition)
    

    Here, we pass in everything we need, the connection object, the table name and the WHERE MySQL clause. We can further abstract this function by doing:

    public function pdo_query(PDO $pdo_connection, $query)
    

    Now, we aren’t restricting our function to just selecting, we can do all sorts of queries.

    But you see that you definitely can pass objects to different functions to work with.

    Passing objects also gives you the nice touch of having type hinting, which would throw an error if a different kind of parameter is entered, helping you to debug.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm following a php pagination tutorial that uses MYSQL but I use MYSQLI object
I have an object-oriented parent-child tree in PHP that I want to clone. The
I'm working on Ubuntu.(Linux) I want to display all .php pages to .html in
<?php $a="php.net s earch for in the all php.net sites this mirror only function
We currently have an error catching script for all our PHP sites. This script
I'm working through this tutorial: http://www.killerphp.com/tutorials/object-oriented-php/php-objects-page-3.php At first he has you create a setter
From my basic understanding in Object Oriented coding, PHP in my case, you want
I'm new to object oriented php, so I'm not sure which classes do I
When programming in PHP I always try to create meaningful 'models' (classes) that correspond
I want to create a 100% object oriented framework in PHP with no procedural

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.