I create my web app with php follow mvc model.
When I set path css,img,js,... i use <link rel="stylesheet" href="./public/css/style.css">
in default controller I got css for my page. But when I call action like http://localhost/assignment/controller/action i lost my css. relative path become http://localhost/assignment/controller/action/public/css/style.css or http://localhost/assignment/controller/action/param/public/css/style.css.
Sounds like you might have a configuration or bundler issue. The quickest - not best fix - for developing would be to move your css file to where the public folder is located. You need to find the root folder where that link is calling from and link there.
If you are using a bundler or transpiler, you might need to look in the configs for what is being bundled.
Also make sure to follow this format for local files.
The right way of setting <a href=""> when it's a local file
Related
I've finished my laravel project and played it in a subfolder on my domain.
https://example.com/swap
So the above is the root of my directory and when I go there, I do get the index. But now every link I press, I'm redirected to the root of my domain. So I'm getting:
https://example.com/events/1
Instead of https://example.com/swap/events/1
Am I forced to change all URLs by hand in my files are is there a way my htaccess can always redirect to this 'swap' folder and place everything behind that?
I've tried using groups in my routes, without success.
Use url for all your links which are inside views folder:
For subfolder link use:
Sub-Folder Link
For root folder links use this syntax:
Index
There might arise issues with stylesheet and javascript in 'swap" sub-folder links with a 404 error. To fix that, use:
<script type="text/javascript" src="{{asset('js/app.js')}}">
<link rel="stylesheet" type="text/css" href="{{asset('css/app.css')}}">
You need to direct your VHOST to laravel's public folder. This is done for security purposes. Ideally your laravel install is outside the public folder, thus you would have yourdomain.com contain your laravel install and rename your public folder to swap.
IF you really want the name swap in your routes you could use route prefix with groups.
Open .env File and Change Your App Url to https://example.com/swap/ and use routes as links of whole application
All Url's Will Work fine.
When putting a laravel application in a subfolder. You need to modify your .htaccess for subfolder hosting. And add the following:
RewriteBase /swap
This way, the app knows when you go to route {{ url('/hello-world') }}, it will ultimately go to "/swap/hello-world"
I need to create custom template for PhpDocumentor. The problem is that paths defined in the template.xml, even when specified as absolute ones, are not resolved correctly. PhpDocumentor looks for them in the vendor directory.
<template>
<author>Code Mine</author>
<email>office#code-mine.com</email>
<description>Template for Confluence API</description>
<version>1.0.0</version>
<transformations>
<transformation writer="twig" source="./index.html.twig" artifact="index.html"/>
<transformation query="indexes.namespaces" writer="twig" source="./namespace.html.twig" />
<transformation query="indexes.classes" writer="twig" source="./class.html.twig" />
</transformations>
</template>
Despite fact that twig templates are located in path to which xml refers, I'm getting error that files don't exist.
EDIT:
I have also tried with setting up all configuration details in phpdoc.xml in hope that paths will be considered relative to configuration file but with no luck.
If you specify a custom template with --template="..." it will (for some strange reason) copy that entire template into the vendor folder together with the original templates, and therefore the path structure in template.xml needs to remain the same. You only need to change eg. templates/clean/ to templates/yourtemplatename/.
I have an issue with caching though. I can't get it to reread my template every time. It has cached it somewhere and I can't for the life of me figure out where. Documentation is really bad and source is worse.
Update:
Finally figured out that it cached my template in the temp folder of my computer. For Windows eg.: c:\Users\<username>\AppData\Local\Temp\phpdoc-twig-cache\. So I just delete that entire folder.
Correct me if I'm wrong but it seems like you can just pass a file path on the CLI
https://www.phpdoc.org/docs/latest/getting-started/changing-the-look-and-feel.html
Using a custom template When you have a company or project-branded template you can also use that with phpDocumentor by providing the location of your template’s folder:
$ phpdoc -d "./src" -t "./docs/api" --template="data/templates/my_template"
you may need to back out of the vendors directory with a few ..'s like so
--template="../../data/templates/my_template"
or pass an absolute path
--template="/var/scratch/foo/data/templates/my_template"
I recently downloaded cakephp-1.3.4. I set it up on my web server. I followed the advanced installation settings. My folder structure is as follows.
/common/
cakephp/
app/
etc...
/htdoc/
The /htdoc folder is the webroot; cakephp resides in the common folder.
I have configured the paths in index.php to point to this folder structure. I have the app up and running. I created a layout, the app has picked it up (along with all the css and images - all that works).
I created a posts_controller.php in cakephp/app/controllers/. Now when I try to access the following page: http://localhost/posts. I get a message that the controller cannot be found and that I should create a app/controllers/posts_controller.php (it already exists!).
Also the strange thing is using the default pages_controller works. I created an about.ctp and dropped it in app/views/pages/about.ctp. Vising http://localhost/pages/about shows up as expected.
SOLUTION:
Sam helped me solve this problem (see the long comment thread below). The problem was I had set relative paths for my ROOT folder. This messed things up. The solution is to either directly set an absolute path or call realpath with your relative path for it to be resolved into the right absolute path.
Make sure your controller class is named correctly (should be PostsController) and inherits from AppController (not strictly necessary but good practice).
I have installed zend framework on my local machine. I have configured a vhost in httpd.conf and have added a line in my hosts file (127.0.0.1 mysite). I am running windows 7. Everything works perfect. The problem is when i upload on a hosting server the paths get mixed up.
I am uploading on a remote dir called zf-framework. To access the index page i need to type this url: http://mysite/zf-framework/public. It displays the index page but when i press any links on the page they get mixed up and end up being something like http://mysite/controller/action when in fact it should be http://mysite/zf-framework/public/controller/action. I have found a work-around for this situation...to use echo $this->baseUrl(link) for any links i have in the layout.phtml. The problem is more serious when it comes to submitting forms. I can't use baseUrl there....or i don't know how to use it. Is there a way to write some general config stuff so that this could be automatically resolved by the framework. Let's say to write something in index.php or bootstrap.php that will fix the paths automatically?
If you're using Zend_Application, then add the following to your configs/application.ini file.
resources.frontController.baseUrl = "/your-path-here"
If you're not using Zend_Application, then do this in your bootstrap, or index.php file.
$front = Zend_Controller_Front::getInstance();
$front->setBaseUrl('/your-path-here');
You won't have to use $this->baseUrl() when submitting a form to the same action and controller (just leave out the action attribute in the form tag), or when using the Redirector action helper. However, links in your view scripts will require you to $this->baseUrl('/url-without-base'), which doesn't seem too bad to me.
I am not 100% on this, but if you specify the route in your routes.ini as zf-framework/public/Controller/Action etc this should fix your issue.
I would see this as a bandaid, but I am not 100% sure on how to properly fix your issue other then you modifying the vhosts file on the remote server to set a document root to the public folder. If that is not an option, well the above should work, but know that all of your files are potentially accessible from everyone (at least your folder structure). I am not sure what harm this can do (if any) other then if your database schema is in the /data directory.
It is better to try and get the public set as the web root, if possible.
I am getting a Missing Helper error when I am trying to upload my cake php files to a shared host.
Undefined variable: javascript
Missing Helper File
It is working fine on my local machine.
I have the following directory structure in shared hosting:(using cpanel)
/home/user/
/app
/cake
/vendors
/public _html
/css
/img
/js
.htaccess
index.php
I have also made all the relevant changes to the index.php file and I was getting the full colored cake php intro page.
The strange thing is that it is recognizing the HTML helper and hence i am able to see my web page with full CSS. However, it is giving problems with javascript and other helpers.
I already have an app_controller file with all helpers well defined in $helpers =array().
Why is it giving this error??
As mentioned above, I have made changes to my cake directory structure. So, do I have to make changes to the paths.php file located in the cake/config folder??
I think that cake is not finding the javascript helper because something is messed up with config files. Is it so or there is some other problem??
in /app/app_controller.php, add:
var $helpers = array('Javascript');
your structure doesn't seem like cakephp structure :-(
Guys, I found a simple way to tackle this problem. I certainly cannot call it the solution for the problem. May be a temporary way to make things work.
I simply replaced
<?php echo $javascript->link(array('tabulator')); ?>
with the standard HTML,
<script type="text/javascript" src="/blog/js/tabulator.js"></script>
and it worked!!
I still don't know the problem with javascript helper. All other helpers, Html, Form and Ajax are working fine. I am also using Gravatar for my blog. So, the Gravatar Helper was also giving problems.
The solution to this problem was weird.
I renamed the helper file gravatar.php instead of Gravatar.php. This worked insipte of the fact that helper file name should begin with a capital letter according to cake naming conventions!!
I also had to solve numerous other problems like making changes to the index.php file so that cake can locate the modified directory structure.
Also, had to make changes to .htaccess file for rewriting the base and directing the blog to the new URL.
Man..so much for rapid development!! :O