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 8673569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:29:30+00:00 2026-06-12T19:29:30+00:00

I have an php object which I want to be accessible whenever I want.

  • 0

I have an php object which I want to be accessible whenever I want. I want to create this object once and keep it persistent so that I don’t have to reload it again. Also I would like this object to be accessible in my controllers/models etc.

Can this be achieved in CodeIgniter/PHP without using session?

Or maybe using session, but will I be able to access its methods?

This object is created using PHP COM library from my dll file

Here is sample of my object:

 $myDllObject = new COM("MyDLL.MyCLass");
  • 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-12T19:29:31+00:00Added an answer on June 12, 2026 at 7:29 pm

    PHP has an execution model where each web request from the host environment generates a new, fresh PHP environment which is destroyed when the request is completed.

    So the simple answer is no, you cannot create an object and persist it between requests. You must “persist” the object in some other way:

    1. Through serialization/deserialization, using sessions, a database, a key-value store like APC, a file on the file system, or some other method.
    2. By having a separate long-running process hold the object, and having PHP objects communicate with it via some IPC method, such as shared memory, pipes, sockets, etc.

    I don’t know much about COM, but since COM objects can be created outside the running process I suspect that there is probably some (not-PHP specific) method of connecting to an existing one rather than creating a new one. (This is essentially option 2 above, using the COM services as the IPC.)

    A little digging through the PHP COM library docs reveals the com_get_active_object() function, which may bring you to a working solution. However, you will probably need to learn more about COM from non-PHP sources. Also, read the big fat warning about using a single COM object concurrently:

    Using com_get_active_object() in a web server context is not always a smart idea. Most COM/OLE applications are not designed to handle more than one client concurrently, even (or especially!) Microsoft Office. You should read » Considerations for Server-Side Automation of Office for more information on the general issues involved.

    This suggests to me that creating a singleton COM object shared among all requests is actually what you don’t want to do!

    If that doesn’t work, PHP has an object serialization method that allows you to serialize the running state of an object to a string and deserialize it back again to the same state. You can customize this by adding the __sleep() and __wakeup() methods to your class. This mechanism has it’s share of quirks and I don’t know how well the PHP COM library proxy objects would support it.

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

Sidebar

Related Questions

I have a need to create a library of Object Oriented PHP code that
I have a javascript object which I want to pass to a PHP file
I have a PHP Object which contains other objects i.e $obj->sec_obj->some_var; I want to
I have a JSON object items which has few items that I want to
I have an object-oriented parent-child tree in PHP that I want to clone. The
I have a function which returns object array like that: <?php function sth() {
I have a JSON object which is generated by PHP. It's an object with
If I have in my php app an object that connects to the database,
I have to share an instance of a config object in PHP. This object
I have a php script that outputs a json-encoded object with large numbers (greater

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.