Laravel Optimize Command with `--force` Option Not Working - php

When I run the php artisan optimize command with the --force option, my application instance doesn't work at http://localhost/project/public/invoice/create.
However, it does work at http://localhost:8000/invoice/create when I run php artisan serve.
Why isn't http://localhost/project/public/invoice/create working? How can I rollback?

The Laravel file structure is set up:
public
|-- css
| -- app.css
|-- js
| -- app.js
| -- some-other.js
|-- index.php
These files referenced as follows:
http://localhost/css/app.css
http://localhost/js/app.js
http://localhost/index.php OR http://localhost/
The /public directory is the base and contains the index.php file, which is the entry point for all requests entering your application and configures autoloading. This directory also houses your assets such as images, JavaScript, and CSS.

Related

Calling Controller method which is in sub directory via Termial/CLI - codeigniter4

My Folder structure is like below in my CI4 Application
App/Controllers
-- Folder1
Controller1.php
Controller2.php
Controller.php
AnotherController.php
From Codeigniter 4 Docs, I know I can call my controller from a terminal like below
$ cd /path/to/project/public
$ php index.php tools message
But How do I call a controller in Sub-directory from terminal
$ cd /path/to/project/public
$ php index.php Folder1 Controller1 method
Either make explicit routes that lead to the "subcontrollers" or just use the fully-qualified namespace in your CLI statement:
php index.php '\App\Controllers\Folder1\Controller1' SomeMethod
This assumes that you've correctly namespaced Controller1.

PSR-4 namespace in generated files with Thrift

I generate php files with Apache Thrift
thrift -out / --gen php:nsglobal=src\\Application\\Package\\Thrift package.thrift
The above command generates code in the following path src/Application/Package/Thrift and set src\Application\Package\Thrift for namespace but I use Psr-4 (with composer) in my project we know src as App so namespace should be App\Application\Package\Thrift
my project structure
src |
| Application |
| | Package |
| | | Thrift
I went generate files in Thrift folder with namespace same as following:
App\Application\Package\Thrift
Do you have an idea to solve this problem?
I try add namespace php App.Application.Package to IDL file and run following command:
thrift -out /src --gen php /data/service.thrift
But it create extra App folder => src/App/Application/Package/Thrift
Declare the namespace in the IDL file:
namespace php Whatever.You.Want
Full example can be found here
Also, remove the nsglobal option and just do
thrift -out / --gen php package.thrift
i need App in namespace and src in folder name
If you need the folder being different from what the namespace says, consider writing a shell script (or batch file) to move the generated files to where you need them to be after Thrift code generation.
PS: Not sure if specifying a root folder as the output target is such a great idea at all.

Using encore webpack with symfony project

I'm using the Encore/Webpack in my Symfony project, but Im having troubles with the installation.
I'm following the official guide: Link to official guide
My project folder:
projectname
---/app
---/assets
/css
/global.scss
/js
/main.js
...
---/node_modules
/.bin
/encore
...
---/web
/build
etc
I was following
Create a new file called webpack.config.js at the root of your
project.
It looks like:
projectname
...
webpack.config.js
I filled it with the example code. Afterwards I wanted to 'build' the assets with the command encore dev on path: projectname\node_modules\.bin
When I do this, I get the following error code:
Running webpack ...
No configuration file found and no output filename configured via CLI option.
A configuration file could be named 'webpack.config.js' in the current directory.
Use --help to display the CLI options.
I have no idea what I'm doing wrong. When I move the webpack.config.js to the .bin folder.. that part works, but than the build doesn't work, because it wants to install the files into .../.bin/build/ which is not correct. I want it into projectname/build like the example.
try this commend it's work for me
install webpack-notifier#^1.6.0 --save-dev

Symfony3 - how can I add a photo using Symfony

I'm using Symfony3 and I want to know how can I add a photo to my website or a css file
Can anyone give me a detailed solution because I saw some people using the asset and they put their photos in \public\images and I didn't understand how it really works knowing that I don't have the folder \public\images in Resources ?
The best way is to use Assetic to manage your assets (css, js, images). You can store them in the directory app/Resources/public and dump them before deploying to the production environment with the command php bin/console assetic:dump --env=prod --no-debug.
Thank you I found a solution by myself
I store the images in src/nomDuBundle/Resources/public then I executed the command php bin/console assets:install.
A folder named Bundle will be created in /web , I found there my Bundle , I took the absolute PATH & in the twig file I used this code :
<img src="{{ asset('bundles/nomBundle/images/votreImage.png') }}" />
It works for those who have a problem with this
AppBundle is recommended by the Assetic documentation to centralize all ll that we need to include in the HTML header.
Is it why a new symfony generation with symfony phar always create a AppBundle ? In any case it is likely.
src/AppBundle directory is just like the ring of the Lord of the Rings, all power of front office is centered there.
In it Create a Resources directory and : images, css, js,... sub-directories.
src/AppBundle
|
-- Resources
|
--public
|
-- images
|
-- css
|
-- js
|
-- ....
install assetic with composer
configure config.yml
configure Appkernel :
class AppKernel extends Kernel{
public function registerBundles(){
$bundles = [
...
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
...
]
...
in twig views :
{% image '#AppBundle/Resources/public/images/example.jpg' %}
<img src="{{ asset_url }}" alt="Example" />
{% endimage %}
command line :
$ php bin/console assetic:dump --env=prod --no-debug
Command line generates directories and image files with automatic names. And it works well.
web
|
-- images
|
-- css
|
-- js
|
-- ....

app/Console/cake vs lib/Console/cake in CakePHP

I'm new to Shell using CakePHP and I couldn't notice how there are 2 cake console application: one at app/Console/cake and other in lib/Console/cake being the second one the one in CakePHP's core.
So far, I have used lib/Console/cake bake -app /path/to/app to bake some MVC classes, but I have never used app/Console/cake before. Also lib/Console/cake is configured in my environment variables.
I want to know the difference of these 2, when to use one or another and why.
Note: I moved my core folder to a different directory, so naturally, app/Console/cake wont find ShellDispatcher, which line should I modify to set the new path to core library?
Are identical, but you should use the one inside app folder:
cd app/
./Console/cake bake
To change the default folder structure and config you must edit these files:
/app/webroot/index.php
/app/webroot/test.php
and un-Comment this line putting your core folder location:
// /usr/lib/mylocation
define('CAKE_CORE_INCLUDE_PATH', DS . 'usr' . DS . 'lib' . DS . 'mylocation');
Take a look at the manual here:
http://book.cakephp.org/2.0/en/installation/advanced-installation.html#sharing-cakephp-libraries-with-multiple-applications
The difference
The difference between the two executables is that one derives the app location from the current working directory, and the other is application specific. This can be highlighted like so:
Normal usage:
www-data # dev [ /tmp/cakephp ] (master=)
-> app/Console/cake
Welcome to CakePHP v2.4.6 Console
---------------------------------------------------------------
App : app
Path: /tmp/cakephp/app/
---------------------------------------------------------------
Reference app executable from different path:
-> cd anywhere
-> /tmp/cakephp/app/Console/cake
Welcome to CakePHP v2.4.6 Console
---------------------------------------------------------------
App : app
Path: /tmp/cakephp/app/
---------------------------------------------------------------
Note the app and path did not change.
cake in path
If /tmp/cakephp/lib/Cake/Console/ is in the path:
-> cd anywhere
-> cake
Welcome to CakePHP v2.4.6 Console
---------------------------------------------------------------
App : xxx
Path: **anywhere**
---------------------------------------------------------------
Note the app and path vary depending on where you are when executing the command.
If you always specify the -app flag, they will function the same, but you'll find it is problematic to use cake in your path if for example you have multiple applications on the same host using different versions of CakePHP.
Fixing paths
If you moved the cake folder, the files you need to edit are:
app/Console/cake.php ($root variable/include_path)
app/webroot/index.php (ROOT constant)
app/webroot/test.php (ROOT constant)
Only the first will affect cli usage.

Categories