{"id":231160,"date":"2022-12-28T15:46:00","date_gmt":"2022-12-28T12:46:00","guid":{"rendered":"https:\/\/wordpress.mediadoma.com\/?p=231160"},"modified":"2022-12-28T15:50:51","modified_gmt":"2022-12-28T12:50:51","slug":"webblaesaren-och-terminalen-visar-olika-versioner-av-php","status":"publish","type":"post","link":"https:\/\/wordpress.mediadoma.com\/sv\/webblaesaren-och-terminalen-visar-olika-versioner-av-php\/","title":{"rendered":"Webbl\u00e4saren och terminalen visar olika versioner av PHP"},"content":{"rendered":"<p>Om du r\u00e5kar se tv\u00e5 olika versioner av PHP n\u00e4r du k\u00f6r:<\/p>\n<ul>\n<li><code>php -v<\/code>i konsolen och bes\u00f6k<\/li>\n<li><code>phpinfo()<\/code>i webbl\u00e4saren<\/li>\n<\/ul>\n<p>D\u00e5 betyder detta vanligtvis att versionen av PHP som din webbserver anv\u00e4nder \u00e4r annorlunda \u00e4n den version av PHP som din kommandorad anv\u00e4nder.<\/p>\n<p><a href=\"https:\/\/wordpress.mediadoma.com\/wp-content\/uploads\/2022\/01\/post-159674-61e6fa65bd75f.png\" data-rel=\"lightbox\"><img decoding=\"async\" class=\"SDStudio-light-box-enable SDStudio-editor-tools-md-imp\" src=\"https:\/\/wordpress.mediadoma.com\/wp-content\/uploads\/2022\/01\/post-159674-61e6fa65bd75f.png\" alt=\"Webbl\u00e4saren och terminalen visar olika versioner av PHP\"><\/a><\/p>\n<p>Specifikt betyder detta att du sannolikt har mer \u00e4n en installation, och att webbservern anv\u00e4nder en version och att terminalen anv\u00e4nder en annan version (ut\u00f6ver att anv\u00e4nda en CLI-version av tolken).<\/p>\n<p>Naturligtvis, om du ser att webbl\u00e4saren och terminalen visar olika versioner av PHP s\u00e5 \u00e4r n\u00e5got fel. Du vill att de ska vara samma, men beroende p\u00e5 hur ditt system \u00e4r konfigurerat kan du beh\u00f6va uppdatera dina milj\u00f6variabler.<\/p>\n<p>Jag hade nyligen problem med detta med olika installationer av PHP installerade via <a href=\"https:\/\/wordpress.mediadoma.com\/sv\/koer-flera-versioner-av-php-med-homebrew\/\" title=\"Homebrew\">Homebrew<\/a> och med min lokala installation av <a href=\"https:\/\/tommcfarlin.com\/laravel-valet-for-wordpress\/\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">Valet<\/a>.<\/p>\n<p><a href=\"https:\/\/wordpress.mediadoma.com\/wp-content\/uploads\/2022\/01\/post-159674-61e6fa6ac1261.png\" data-rel=\"lightbox\"><img decoding=\"async\" class=\"SDStudio-light-box-enable SDStudio-editor-tools-md-imp\" src=\"https:\/\/wordpress.mediadoma.com\/wp-content\/uploads\/2022\/01\/post-159674-61e6fa6ac1261.png\" alt=\"Webbl\u00e4saren och terminalen visar olika versioner av PHP\"><\/a><\/p>\n<p>Det h\u00e4r \u00e4r vad jag gjorde f\u00f6r att fixa det.<\/p>\n<p>Jag anv\u00e4nder Z-Shell och <a href=\"https:\/\/ohmyz.sh\/\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">Oh My Zsh<\/a> s\u00e5 du kan beh\u00f6va anpassa f\u00f6ljande steg f\u00f6r att matcha ditt skal (som om du anv\u00e4nder Bash). Men k\u00e4rnan i allt \u00e4r som f\u00f6ljer.<\/p>\n<p>F\u00f6rst m\u00e5ste du veta var Homebrew har installerat PHP. Detta kan \u00e5stadkommas genom att k\u00f6ra i <code>which php<\/code>terminalen. Det borde returnera n\u00e5got s\u00e5 h\u00e4r:<\/p>\n<p><a href=\"https:\/\/wordpress.mediadoma.com\/wp-content\/uploads\/2022\/01\/post-159674-61e6fa722faa3.png\" data-rel=\"lightbox\"><img decoding=\"async\" class=\"SDStudio-light-box-enable SDStudio-editor-tools-md-imp\" src=\"https:\/\/wordpress.mediadoma.com\/wp-content\/uploads\/2022\/01\/post-159674-61e6fa722faa3.png\" alt=\"Webbl\u00e4saren och terminalen visar olika versioner av PHP\"><\/a><\/p>\n<p>Och motsvarande versionsinformation n\u00e4r den k\u00f6rs <code>php -v<\/code>b\u00f6r se ut s\u00e5 h\u00e4r:<\/p>\n<p><a href=\"https:\/\/wordpress.mediadoma.com\/wp-content\/uploads\/2022\/01\/post-159674-61e6fa7727cdd.png\" data-rel=\"lightbox\"><img decoding=\"async\" class=\"SDStudio-light-box-enable SDStudio-editor-tools-md-imp\" src=\"https:\/\/wordpress.mediadoma.com\/wp-content\/uploads\/2022\/01\/post-159674-61e6fa7727cdd.png\" alt=\"Webbl\u00e4saren och terminalen visar olika versioner av PHP\"><\/a><\/p>\n<p>D\u00e4refter m\u00e5ste du se till att din <code>zshrc<\/code>fil <a href=\"https:\/\/gist.github.com\/tommcfarlin\/10128f3afda5affbe12f9b1c8a6955cd#file-00-zshrc-sh\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">inneh\u00e5ller en referens<\/a> till bin\u00e4rfilen som utmatas ovan (och den b\u00f6r vara i denna ordning):<\/p>\n<pre><code># If you come from bash you might have to change your $PATH.\n# export PATH=$HOME\/bin:\/usr\/local\/bin:$PATH\n\n# Path to your oh-my-zsh installation.\nexport ZSH=\"\/Users\/tommcfarlin\/.oh-my-zsh\"\n\n# Set name of the theme to load --- if set to \"random\", it will\n# load a random theme each time oh-my-zsh is loaded, in which case,\n# to know which specific one was loaded, run: echo $RANDOM_THEME\n# See https:\/\/github.com\/robbyrussell\/oh-my-zsh\/wiki\/Themes\n# ZSH_THEME=\"robbyrussell\"\nZSH_THEME=\"avit\"\n\n# Set list of themes to pick from when loading at random\n# Setting this variable when ZSH_THEME=random will cause zsh to load\n# a theme from this variable instead of looking in ~\/.oh-my-zsh\/themes\/\n# If set to an empty array, this variable will have no effect.\n# ZSH_THEME_RANDOM_CANDIDATES=( \"robbyrussell\" \"agnoster\") # Uncomment the following line to use case-sensitive completion.\n# CASE_SENSITIVE=\"true\"\n\n# Uncomment the following line to use hyphen-insensitive completion.\n# Case-sensitive completion must be off. _ and - will be interchangeable.\n# HYPHEN_INSENSITIVE=\"true\"\n\n# Uncomment the following line to disable bi-weekly auto-update checks.\n# DISABLE_AUTO_UPDATE=\"true\"\n\n# Uncomment the following line to change how often to auto-update (in days).\n# export UPDATE_ZSH_DAYS=13\n\n# Uncomment the following line to disable colors in ls.\n# DISABLE_LS_COLORS=\"true\"\n\n# Uncomment the following line to disable auto-setting terminal title.\n# DISABLE_AUTO_TITLE=\"true\"\n\n# Uncomment the following line to enable command auto-correction.\nENABLE_CORRECTION=\"true\"\n\n# Uncomment the following line to display red dots whilst waiting for completion.\nCOMPLETION_WAITING_DOTS=\"true\"\n\n# Uncomment the following line if you want to disable marking untracked files\n# under VCS as dirty. This makes repository status check for large repositories\n# much, much faster.\n# DISABLE_UNTRACKED_FILES_DIRTY=\"true\"\n\n# Uncomment the following line if you want to change the command execution time\n# stamp shown in the history command output.\n# You can set one of the optional three formats:\n# \"mm\/dd\/yyyy\"|\"dd.mm.yyyy\"|\"yyyy-mm-dd\"\n# or set a custom format using the strftime function format specifications,\n# see 'man strftime' for details.\n# HIST_STAMPS=\"mm\/dd\/yyyy\"\n\n# Would you like to use another custom folder than $ZSH\/custom?\n# ZSH_CUSTOM=\/path\/to\/new-custom-folder\n\n# Which plugins would you like to load?\n# Standard plugins can be found in ~\/.oh-my-zsh\/plugins\/*\n# Custom plugins may be added to ~\/.oh-my-zsh\/custom\/plugins\/\n# Example format: plugins=(rails git textmate ruby lighthouse)\n# Add wisely, as too many plugins slow down shell startup.\nplugins=(vscode)\n\nsource $ZSH\/oh-my-zsh.sh\n\n# User configuration\n\n# export MANPATH=\"\/usr\/local\/man:$MANPATH\"\n\n# You may need to manually set your language environment\n# export LANG=en_US.UTF-8\n\n# Preferred editor for local and remote sessions\n# if [[ -n $SSH_CONNECTION ]]; then\n#   export EDITOR='vim'\n# else\n#   export EDITOR='mvim'\n# fi\n\n# Compilation flags\n# export ARCHFLAGS=\"-arch x86_64\"\n\n# Set personal aliases, overriding those provided by oh-my-zsh libs,\n# plugins, and themes. Aliases can be placed here, though oh-my-zsh\n# users are encouraged to define aliases within the ZSH_CUSTOM folder.\n# For a full list of active aliases, run `alias`.\n#\n# Example aliases\n# alias zshconfig=\"mate ~\/.zshrc\"\n# alias ohmyzsh=\"mate ~\/.oh-my-zsh\"\n#export PATH=\"\/usr\/local\/sbin:$PATH\"\n#export PATH=\"\/usr\/local\/sbin:$PATH\"\nexport PATH=\"\/usr\/local\/opt\/icu4c\/bin:$PATH\"\nexport PATH=\"\/usr\/local\/opt\/icu4c\/sbin:$PATH\"\nexport PATH=\"\/usr\/local\/bin:$PATH\"\nexport PATH=\"\/usr\/local\/sbin:$PATH\"\nexport PATH=\"\/usr\/local\/opt\/php@7.2\/bin:$PATH\"\nexport PATH=\"\/usr\/local\/opt\/php@7.2\/sbin:$PATH\"\nexport PATH=~\/.composer\/vendor\/bin:$PATH\n<\/code><\/pre>\n<p>D\u00e4refter m\u00e5ste <a href=\"https:\/\/gist.github.com\/tommcfarlin\/10128f3afda5affbe12f9b1c8a6955cd#file-01-source-zshrc-txt\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">du uppdatera din skalsession<\/a> f\u00f6r att ladda om milj\u00f6variablerna.<\/p>\n<p>N\u00e4r du har gjort det, b\u00f6r du se samma version i terminalen som du ser i en exempel p\u00e5 PHP-fil n\u00e4r du k\u00f6r <code>phpinfo()<\/code>.<\/p>\n<p><div id=\"PostUnique_PostSource\" style=\"padding-top: 50px\">Inspelningsk\u00e4lla:  <a target=\"_blank\" rel=\"noopener nofollow\" href=\"\/\/tommcfarlin.com\" class=\"external external_icon\">tommcfarlin.com<\/a><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Om du ser att webbl\u00e4saren och terminalen visar olika versioner av PHP \u00e4r n\u00e5got fel. H\u00e4r \u00e4r ett s\u00e4tt att \u00e5tg\u00e4rda det fr\u00e5n att h\u00e4nda.<\/p>\n","protected":false},"author":1,"featured_media":159675,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_wp_rev_ctl_limit":""},"categories":[848,901,807,724],"tags":[1173],"class_list":["post-231160","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-handledningar","category-koda","category-php-9","category-utvecklaren","tag-affiai-sv"],"_links":{"self":[{"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/posts\/231160","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/comments?post=231160"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/posts\/231160\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/media\/159675"}],"wp:attachment":[{"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/media?parent=231160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/categories?post=231160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/tags?post=231160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}