Your original config version failed because Zend was looking for a resource
plugin called WSMapper, which it couldn't find.

The way I see it, you have two options.

1) Create a resource plugin.
This is probably the best way to do it, although it's a bit more complicated
because you have to create a class that is the resource. The resource
essentially allows you to load an instance of Default_Model_WSMapper on
demand.
Then, have your setOptions() method include the wsURL key. Then you can set
the URL when you construct the object. This is how you'd do it with the
resource plugin.
http://framework.zend.com/manual/en/zend.application.theory-of-operation.html#zend.application.theory-of-operation.resources

2) Have your bootstrap set the URL to the Zend_Registry.
Zend_Registry is just a glorified globals. You can set the value in your
bootstrap (which has access to your config), and then access it within your
model.
http://framework.zend.com/manual/en/zend.registry.using.html

Konr

On Tue, Feb 9, 2010 at 2:18 PM, Dan F <[email protected]> wrote:

> I've very new to Zend framework. I have a project that uses webservice
> calls instead of a database. I have a Webservice model that looks like:
>
> class Default_Model_WSMapper
> {
>       protected $_ws;
>       //dev webservices
>       protected $_wsURL = "http://services.webserviceurl.net:9064";;
>       
>       //live web services
> //    protected $_wsURL = "http://services.webserviceurl.net:18086";;
>       
>       public function __construct(array $options = null){
>                if (is_array($options)) {
>             $this->setOptions($options);
>         }
>               $this->_ws = new Zend_Rest_Client($this->getWSUrl());
>       }
>       
>       public function setWSUrl($url)
>     {
>       $this->_wsURL = (string)$url;
>     }
>
>     public function getWSUrl()
>     {
>       return $this->_wsURL;
>     }
>
>      public function get( $parameters = array(), $path = '',$resultType = 
> 'json'){
>       ...
>      }
>
>      ...
> }
>
> In my other models this is accessed by
>
>
> $this->_mapper = new Default_Model_WSMapper();
>
> I would like to move the URL that is currently hardcoded here into
> application.ini but I'm unsure of the best way to access the values in
> application.ini and get the class to initialize with the url already set.
> For the ini file I have tried
>
>
> [testing : production]
> phpSettings.display_startup_errors = 1
> phpSettings.display_errors = 1
> resource.WSMapper.params.wsURL  = "http://services.webserviceurl.net:9064";
>
> [development : production]
> phpSettings.display_startup_errors = 1
> phpSettings.display_errors = 1
> resource.WSMapper.params.wsURL = "http://services.webserviceurl.net:18086";
>
> which causes an error so I adjusted it to
>
>
> [testing : production]
> phpSettings.display_startup_errors = 1
> phpSettings.display_errors = 1
> WSMapper.params.wsURL  = "http://services.webserviceurl.net:9064";
>
> [development : production]
> phpSettings.display_startup_errors = 1
> phpSettings.display_errors = 1
> WSMapper.params.wsURL = "http://services.webserviceurl.net:18086";
>
> I used the quick start tutorial as a base for my code and can post more if
> needed. Thanks in advance for the help.
> ------------------------------
> View this message in context: need help with 
> application.ini<http://n4.nabble.com/need-help-with-application-ini-tp1474967p1474967.html>
> Sent from the Zend Framework mailing list 
> archive<http://n4.nabble.com/Zend-Framework-f634138.html>at Nabble.com.
>

Reply via email to