use Symfony\Component\DependencyInjection\ContainerBuilder; // create a new container builder $containerBuilder = new ContainerBuilder(); // define a new scope for user sessions $containerBuilder->addScope('user_session'); // register a service with the user_session scope $containerBuilder->register('user_preferences', UserPreferences::class) ->setScope('user_session'); // set the session ID to the user_session scope $containerBuilder->enterScope('user_session'); $containerBuilder->set('session_id', '12345'); // retrieve the user_preferences service within the user_session scope $userPreferences = $containerBuilder->get('user_preferences');In this example, a new scope called "user_session" is defined, and a service called "user_preferences" is registered with the scope. When the session ID is set to "12345", the scope is entered and the user_preferences service is retrieved within that scope. Overall, addScope is a useful method for defining custom contexts within the Symfony service container, and can help make services and resources more modular and reusable.