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

  • Home
  • SEARCH
  • 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 8612135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:33:07+00:00 2026-06-12T04:33:07+00:00

Some people have reported issues with accessing, setting, or getting the right value from

  • 0

Some people have reported issues with accessing, setting, or getting the right value from baseUrl() in a view script. But I’m wondering why it is necessary to use it at all, at least in a situation like mine where the ZF application is on a virtual private host (Amazon EC2) where I have full control of the directory structure and apache rewrite rules, as well as routes.

I know, for example, that in the filesystem foo.jpg lives in public/images/foo.jpg, and that the application’s mod_rewrite will direct all requests to public – so in my view scripts it’s a lot simpler/clearer and more efficient to write something like

<img src="/images/foo.jpg" />

instead of

<img src="<?php echo $this->baseUrl();?>/images/foo.jpg" />

What sort of future-proofing robustness or other benefit does the use of baseUrl() really provide? So far I haven’t used it at all, and had no problem. But I’ve inherited some code that uses it, and my inclination is to strip out those uses whenever I’m editing a view script that contains them. Would I regret that later?

  • 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-12T04:33:08+00:00Added an answer on June 12, 2026 at 4:33 am

    Used this way, it’s not really useful, but on the other hand, using it this way

    echo $this->baseUrl('/images/foo.jpg')
    

    might prove to be useful in the future since you can add logic before printing the URL. Imagine that in a few years your website grows way more than you expected and you have to move all your static content to a Content delivery network (CDN) you will have to manually (or with search and replace) correct all your images/css/js instances URLs. With the baseUrl() (or as name it assetUrl()) you would just have to add your CDN’s url and it will be fixed everywhere in your application.

    EDIT

    I found a use for the baseUrl() in the code you inherited :

    It would allow you to add a common URL part to all of your links and references, in the case that your site is not at the root of the domain

    i.e. : www.mysite.com/zf-app/
    

    In your config file you would just have to add

    resources.frontController.baseUrl = "/zf-app/"
    

    for it to work, and all of your links would be prepended with that part

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

Sidebar

Related Questions

Some people have mentioned RockScroll and MetaScroll in This Question , but those only
I have a app to manage book orders from some people, here is the
I would love to get some tips from other people that have had this
Okay, so I've read some other people have had this problem, but they either
I have recently put an app on google play and some people have reported
I am making a program like yelp. Some people have some accounts. So I
I'm hoping people have some ideas to help solve this problem. I am developing
I have seen some people in SO commenting that Singleton Pattern is an anti-pattern.
I have seen prefix N in some insert T-SQL queries. Many people have used
Currently we have an application who use spring who support mysql. Some people prefer

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.