I downloaded YiiShop extension from here
Then I followed the instruction:
1.Make a folder in my webapp named modules, then extracted the extension there
2.Do some configuration in webapp/protected/config/main.php
'modules' => array(
...
'shop' => array('debug' => 'true'),
...
),
3.I tried to run it as instructed, webapp/shop/install, but it turns error:
Alias "shop.ShopModule" is invalid. Make sure it points to an existing PHP file and the file is readable.
Any ideas how to fix this?
Thanks.
may be a permission error..
What operating system you are using?
If linux then try this command in terminal -
sudo chmod 777 -R /path_to_root_dir/project_name
warning : do not use this command in your file system!
Related
I worked on a team and then clone the laravel/php codes from our repository. When I serve the laravel on localhost, it cannot find all the file inside the public directory and throw an error on the terminal:
[404]: GET /public/css/style.css - No such file or directory
Many answers to similar issues advise me to change the codes in the blade.php file. The problem is that I can't edit the blade.php because it works fine on other team members even though we have the same ubuntu, PHP, and laravel version and .env file.
What I have tried:
Run composer install and composer update
Try different browsers such as firefox and chromium-based browsers
Run php artisan storage:link
Restart apache2
Run npm install and npm run dev
I think there is some package or something missing.
List of paths I get from dd($__data):
"path" => "/project-directory/project-name/app"
"path.base" => "/project-directory/project-name"
"path.lang" => "/project-directory/project-name/resources/lang"
"path.config" => "/project-directory/project-name/config"
"path.public" => "/project-directory/project-name/public"
"path.storage" => "/project-directory/project-name/storage"
"path.database" => "/project-directory/project-name/database"
"path.resources" => "/project-directory/project-name/resources"
"path.bootstrap" => "/project-directory/project-name/bootstrap"
Have you tried?
php artisan storage:link
You need first run
php artisan storage:link
For more details check https://laravel.com/docs/8.x/filesystem
Then you must be check your .env values.
Is correctly APP_URL=
Also in your exception is strange
/public/.../...
Reason is wrong configuration.
First check your .env values like
APP_URL=...
FILESYSTEM_DRIVER=public
then check config/filesystems.php
I am trying to display an image in my Laravel application. The image comes from another disk which is a samba share. I followed the configuration instructions from the Laravel Doc, here is my setup:
filesystems.php
'shop_storage' => [
'driver' => 'local',
'root' => env('SHOP_STORAGE_PATH', base_path('shop_storage')),
'dir' => [
'public' => 0777,
'private' => 0777,
]
],
My samba share is mounted into the root folder /shop_storage inside my Laravel application with the following command:
sudo mount.cifs //PATH_TO_FILE_SHARE/ARMMAG ./shop_storage -o credentials=$HOME/.smbcredentials,rw,file_mode=0777,dir_mode=0777,mfsymlinks
I correctly see all files when I open the folder.
Then, I added a Symlink from /public/storage to /shop_storage with the following command:
sudo ln -s /shop_storage /public/storage (Using full path starting at /home, removed here for privacy)
When I open /public/storage, I correctly see the symlink pointing to the samba share. If I click to open it, I see all the files. The file I am looking for exists.
The problem is when I am trying to display it in my webpage, the request return a 404.
Here is some of the things that I have tried:
<img src="{{\Storage::disk('shop_storage')->url('products/16/MAZJKj59EY0XQ57oKIibKr33eZ5dsqAPx44MCHHJ.png')}}">
<img src="http://localhost:8000/shop_storage/products/16/MAZJKj59EY0XQ57oKIibKr33eZ5dsqAPx44MCHHJ.png">
<img src="{{asset('products/16/MAZJKj59EY0XQ57oKIibKr33eZ5dsqAPx44MCHHJ.png')}}">
<img src="{{asset('storage/products/16/MAZJKj59EY0XQ57oKIibKr33eZ5dsqAPx44MCHHJ.png')}}">
What am I doing wrong?
Edit
After some try/error, I managed to get a different response with the following syntax:
<img src="{{asset('storage/shop_storage/products/16/MAZJKj59EY0XQ57oKIibKr33eZ5dsqAPx44MCHHJ.png')}}">
Now, I am getting the foloowing error
You don't have permission to access /storage/shop_storage/products/16/MAZJKj59EY0XQ57oKIibKr33eZ5dsqAPx44MCHHJ.png on this server.
My permission are set to 777, what could cause this?
What I ended up doing to make this work is mount my share directly into public/storage instead of using symlinks. Then any I could access the file using the laravel asset helper:
<img src="{{asset('storage/products/16/MAZJKj59EY0XQ57oKIibKr33eZ5dsqAPx44MCHHJ.png')}}">
The error I am getting is
Warning: Phalcon\Mvc\View\Engine\Volt\Compiler::compileFile(../app/views/index/index.phtml.php): failed to open stream: Permission denied in /Users/mattstephens/Sites/magpie/public/index.php on line 26 Phalcon Exception: Volt directory can't be written
I have declared the volt engine usage in my bootstrap like so
$view->registerEngines(array(
'.phtml' => 'Phalcon\Mvc\View\Engine\Volt'
));
The mention of line 26 in my code points to the application handle function shown below
echo $application->handle()->getContent();
Is this a permissions related thing or due to a missing directory?
Unless you specify a different folder for Volt to compile its templates, the folder where the view file is located will be used to create the relevant compiled file.
You can change this behavior by setting the proper option when you register your service as such:
use \Phalcon\Mvc\View as PhView;
use \Phalcon\Mvc\View\Engine\Volt as PhVolt;
...
public function initView($options = array())
{
$config = $this->di['config'];
$di = $this->di;
$this->di['volt'] = function ($view, $di) use ($config) {
$volt = new PhVolt($view, $di);
$volt->setOptions(
array(
'compiledPath' => $config->app_volt->path,
'compiledExtension' => $config->app_volt->extension,
'compiledSeparator' => $config->app_volt->separator,
'stat' => (bool) $config->app_volt->stat,
)
);
return $volt;
};
/**
* Setup the view service
*/
$this->di['view'] = function () use ($config, $di) {
$view = new PhView();
$view->setViewsDir($config->app_path->views);
$view->registerEngines(array('.volt' => 'volt'));
return $view;
};
}
The $config will store all the information you need. By using the compiledPath you instruct Volt to compile the templates there and then serve them to the front end. That folder needs to be writeable for the user that runs your web server www-data or other and can be outside your public folder.
The file structure I usually use is:
app
\controllers
\models
\views
public
\js
\css
\img
var
\volt
\logs
\config
\cache
Change volt file permission (Inside app/cache) to 777 .Its working fine
Contrary to several of the other answers here, don't just willy-nilly set permissions to 0777 and pretend everything's okay, that's completely ridiculous. Your server needs to write to the volt folder inside your cache directory.
You might need to create the folder first.
sudo mkdir cache, and sudo mkdir cache/volt. Then chown that folder with whatever is the username that your server runs.
NOTE: Depending on your configuration, the cache folder might be located at the project root and not inside app.
For example, if your server launches under the permissions of user named 'www-data' (which is most common), after creating the proper folder structure, the following command will fix your issue:
sudo chown www-data:www-data -R cache
I have just made "app/cache" folder with 777 permitions) It works))
change the "app/cache" folder permission to 777.
in my mac i did like this.
navigate inside the app folder of our phalcon framework
[chmod ugo=rwx cache]
make sure the cache folder permission is 777 by typing [ls -l].
Changing the app/cache and app/cache/volt with these commands worked for my project structure.
chmod -R a+w app/cache
chmod -R a+w app/cache/volt
Just go to /project_name/store/app/config/config.php and change cacheDir from 'cacheDir' => __DIR__ . '/../../app/cache/' to 'cacheDir' => __DIR__ . '/../../cache/'.
Also, change its write permission to 777.
You should change ownership of your project directory with chown command,
chown -R your_system_user:webserver_user yourproject/
Check if the baseUri in the config.php is same as the installation directory
if the issue persist, tail nginx logs tail -f /var/log/nginx/*.log.
Also try use sudo setenforce 0. This worked for me.
I am having some trouble configuring doctrine orm on windows 8, php 5.4. I have installed Doctrine using Composer.
I have followed the docs to the letter but when I run any commands, php vendor/bin/doctrine orm:schema-tool:create for example, my command line just outputs
SRC_DIR="`pwd`"
cd "`dirname "$0"`"
cd "../doctrine/orm/bin"
BIN_TARGET="`pwd`/doctrine"
cd "$SRC_DIR"
"$BIN_TARGET" "$#"
I have also tried php vendor/bin/doctrine.php .... but it just prints out the above.
I have followed Doctrine's guide to the letter. Has anyone seen this before and if so, can you suggest anything?
i found a solution
there are also a bin folder in vendor/doctrine/orm/bin/ you can use this one like this
php vendor/doctrine/orm/bin/doctrine orm:schema-tool:create
make sure you have root folder and a cli-config.php file is present in root folder.
below is location where i found a solution
https://groups.google.com/forum/#!msg/doctrine-user/_ph183Kh-5o/_P_coljB-dcJ
this is working fine for me .
I had the same problem. The following solution worked for me:
"vendor/bin/doctrine.bat" orm:schema-tool:create
So, basically you:
use the ".bat" file provided by Doctrine and
enclose the call to that ".bat" file in quotes.
My Environment
Windows 7 Professional (x64)
PHP 5.5.12
Doctrine ORM 2.4.4
Do not write "php..." (it will write the file content)
Just "vendor\bin\doctrine orm:schema-tool:create" do the job (from the project root eg. c:\php\theProject).
Next, you will need a "cli-config.php" in the project root...
For Window version use backward slash "\"
vendor\bin\doctrine orm:schema-tool:create
not forward slash "/"
vendor/bin/doctrine orm:schema-tool:create
You can either install something like git bash or simply use the PHP version of the script:
php vendor\bin\doctrine.php orm:info
Obviously, the php binary directory should be in your PATH environment variable, otherwise, it's something like:
C:\path\to\php.exe vendor\bin\doctrine.php orm:info
Copy doctrine.bat (located at vendor/bin/doctrine.bat) to your project root directory
Create a bootstrap.php file in any path inside your project root directory with the following content:
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
$paths = array("../model");
$isDevMode = false;
$dbParams = array(
'driver' => 'pdo_mysql',
'host' => 'localhost',
'user' => 'root',
'password' => '',
'dbname' => 'angular_php',
);
$config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
$entityManager = EntityManager::create($dbParams, $config);
Create a cli-config.php file in your project root directory with the following content:
<?php
use Doctrine\ORM\Tools\Console\ConsoleRunner;
// replace with file to your own project bootstrap
require_once 'path/to/file/bootstrap.php';
return ConsoleRunner::createHelperSet($entityManager);
Execute from a command line window (CMD):
c:\path\to\project\root\directory>doctrine --help
It's done!
I found it wasnt returning anything from the doctrine.php.bat. Turns out it was a PHP error in my cli-config.php file
Using Cygwin on Windows with doctrine installed via composer, was having the same problem
resolved by:
vendor/bin/doctrine.bat orm:convert-mapping
if you are still having issues you can run the cli script using php to get the console tools running:
for example
php cli-config.php orm:schema-tool:create
All the answers on this question are either outdated or outright incorrect. In my case, I observed, after installing the the library, the "\vendor\doctrine\orm\" folder was completely empty. The docs ask you to run vendor/bin/doctrine, which in turn attempts to call "vendor\doctrine\orm\bin\doctrine[.php]" (The php file extension is optional). After discovering this, I downloaded the library from the git repository and replaced the composer-installed version.
php vendor/doctrine/orm/bin/doctrine
then works fine.
Also, beware of the common misconception that the cli-config.php file must exist in the root of your project. It's fine to leave it in your config folder
When I go to /fileDownload I receive a 500 Internal Server Error - RuntimeException:
The process stopped because of a "0" signal.
Controller Action:
public function fileAction()
{
$html = $this->render('MyBundle:Downloads:file.html.twig', array(
'fileNumber' => '1234'
));
return new Response(
$this->get('knp_snappy.pdf')->getOutputFromHtml($html),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="file.pdf"'
)
);
}
I've used terminal commands for WKHTMLTOPDF and it has successfully generated the PDF. It just will not work in Symfony2 app.
In my config.yml:
knp_snappy:
pdf:
enabled: true
binary: /usr/local/bin/wkhtmltopdf
options: []
I'm assuming Symfony is issuing an exec() at some stage. You need to get the exact command line error returned. The fact it works for you in a terminal session doesn't necessarily mean it will work when a different user/process is running it.
Check permissions on wkhtmltopdf that apache or whoever is running your web server has access to run the command.
Also, check this question out wkhtmltopdf: cannot connect to X server and also the first post here: http://geekisland.org/index.php?m=05&y=11&entry=entry110518-114630
X Server is required to run certain builds of wkhtmltopdf and it is not present when running via cron or from within an apache process. If this is the case you need to use the bash wrapper in the first link above.
Be sure that wkhtmltopdf is indeed in the folder you specify, with correct permissions: /usr/local/bin/wkhtmltopdf
I am successfully using KNP Snappy Bundle with Symfony 2.0, try using RenderView instead of render when generating the html (check my code that is working):
Controller:
$html = $this->renderView('YOPYourOwnPoetBundle:thePoet:poemPDF.html.twig', array(
'poem' => $customizedPoem,
'fontType' => $fontType,
'fontSize' => $formData['fontSize'],
'fontWeight' => $fontWeight,
'fontStyle' => $fontStyle,
));
return new Response(
$this->get('knp_snappy.pdf')->getOutputFromHtml($html),
200,
array(
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="'.$session->get('poemTitle').'.pdf"',
)
);
I had this same issue and i finally solved it, my advice is if you installed the wkhtmltopdf lib from your OS repos then remove it, and download the static version from the google code website, and don't use version 11rc, use the version 9 static lib, it's the one that worked with me.
http://code.google.com/p/wkhtmltopdf/downloads/list
It looks like the selinux is blocking your command, I had the same issue once but I solved it by disabling the SELinux and now I'm able to generate the pdf file using wkhtmltopdf+php.
exec("/usr/local/bin/wkhtmltopdf http://www.google.com /var/www/html/google.pdf");
To disable selinux run setenforce 0,
try again and see if it works.
Re-enable it with setenforce 1
But disabling selinux is not the best solution for this, you need to extend it instead using audit2allow, it will automatically create a custom policy module that will resolve this issue,
First install audit2allo if not already installed
yum -y install policycoreutils-python
grep httpd_t /var/log/audit/audit.log | audit2allow -m httpdlocal > httpd.te
checkmodule -M -m -o httpdlocal.mod httpd.te
semodule_package -o httpdlocal.pp -m httpdlocal.mod
semodule -i httpdlocal.pp
try again and see if it works
I experienced the same issue on same scenario with wkhtmltopdf. And I got rid of with the following command:
setsebool httpd_execmem on